Using a Grid component, we wish to sort and filter rows using hidden values.
Sort and filters are working fine with visible values,
but we have now changed the format used for display,
and we wish to use previous values for sort and filtering.
We are using the ArrayStore, without any proxy.
We are looking for a solution on the client side, in JavaScript only
(no round trip to the server).
http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.ArrayStore
suggest look at methods sort() and filter(), others also can be usefull
Related
We are loading local data into jqgrid using the "jsonstring" datatype (I think this should behave the same as an AJAX request managed by jqgrid?). We are also using groupBy, sorting and custom cell formatting. I'm trying to get this working with structured cell data, like so:
var jqGridData = {"total":1,"page":1,"records":10,
"rows":[{
"id":"24_DisclosureFI",
"cell":["True", {"Value":"24_DisclosureFI","Source":"Input","OriginalValue":null}]
]} }
and so on. The idea being that some of our cellAttr function can use the additional info to make decisions on how to format that specific cell. However, adding this extended structure causes issues with grouping.
We've included a sortType function which gets the embedded cell value, and a customFormatter that does the same. These work, however when doing a groupBy it just takes the first cell value it finds and sticks everything in it. I've tried defining isInTheSameGroup() but it never gets called when we have the structured data (it works fine on non structured cell data).
If we turn off the structured data, all works fine (except we can't display the cell formatting we want). If we turn off the grouping, then the sorting/cell formatting works fine. But can't seem to find a combination where both works.
Any suggestions?
In general we call the jqgrid as in$("#grid_loc").jqGrid({});
But i want to specify the context like $("#grid_loc",context).jqGrid({}). But this is not working. Can somebody help in this?
I have to load server side data using url option.
Infact i occured to have this, as i have tabs on my page.
In each tab, i have to have a jqgrid, not different grids but same grid with different data .
Here i am getting the tab context using var tabset = $("div.tabset");
newdivid = $("div[class*='active_tab']",tabset).attr("id");
var newmenudivid = $("#"+newdivid);
And
the grid code as
$("#grid_workflow", newmenudivid).jqGrid({....});
I have been trying to find out a way to do this. you can find some of my effort in the comments section of the link
how to develop same jqgrid in multiple tabs
i was successful with id overwriting for the same purpose. But that is not a good way though. So i am forced to have another approach ie. context
I suppose that you misunderstand some important things which corresponds to id attribute. The most important that all elements on the page having id attribute have to have unique value of the attribute. In other words the ids have to be unique over the whole HTML page.
So if you need create for example tree grids inside of tree tabs you have to define different id attributes for every grid. For example; grid_workflow1, grid_workflow2, grid_workflow3. If you create the tabs and grids dynamically then you can have some variable in the outer scope (for example global variable) and increase the value of the variable. You can construct id of the grid using some prefix (like "grid_workflow") and the value of the variable. In the way you can create multiple grids with unique ids. Many JavaScript libraries uses the way to generate unique id attribute. Ij you want you can use $.jgrid.randId() method which will returns you unique strings which can be used as ids.
Because of the syntax $("#grid_workflow", newmenudivid) you should understand one important thing. I would recommend never use it. The reason is very easy. It could help only if you have id duplicates. In all other cases if will works exactly like $("#grid_workflow") but slowly. The reason is easy to understand. Web browser hold internally the list if all ids on the page and if you use getElementById method directly of indirectly (in $("#grid_workflow")) the searching of the element with the required id will be like searching in the index in the database. So you will have best performance results. If you use $("#grid_workflow", newmenudivid) then you don't allow web browser to use the index of elements by id. So the usage of context will follow to slow searching throw all children elements of newmenudivid. So you should avoid usage of jQuery context with id selectors.
I want to implement DHTML grid . Which required server side sorting and pegging with ajax support.
Dose any one having any idea about how to implement this.
If you want to implement server side sorting then it does not matter what technology you are using in the front end.
On a conceptual level you can do the following things:
Write a SortingServlet which takes your grid and sorts it according to the request parameters passed to it and renders the output in the form of json(not strictly required but good to have)
Use jQuery to make a Ajax call to this servlet and then format the response when you get it back.
I have a Dojo Grid that I'm filtering with a query that's set in a javascript function.
function filter() {
var grid = dojo.byId("gridNode");
grid.setQuery({fieldName:"Some Text"});
}
What I'd really like to do, though, is filter it so that it shows all entries where the fieldName value is not empty. Does anyone know if there's a way to do this with the Dojo Grid Query, or any other solution that will work with Dojo Grid?
If you are using dojo 1.4 and an dojo.data.ItemFileReadStore you can use a regular expression so the following should work:
grid.setQuery({fieldName:"[^]+"});
According to the following documentation page, not all of the data stores may implement regular expression usage in the query but you can try it out:
http:(slash)(slash)docs.dojocampus.org/dojo/data/ItemFileReadStore
(replace slash slash with //, as a new user, spam prevention prevents me from posting more than one hyperlink)
You might also want to look into using the filter property of the Grid to accomplish what you want, if you want to filter based on some input. Look at this example:
http://docs.dojocampus.org/dojox/grid/DataGrid#filtering-data
It would basically just be something like:
grid.filter({fieldName:"[^]+"});
I've been having a look at several MVC frameworks (like rails, merb, cakephp, codeignitier, and similars...)
All the samples I've seen are basically plain and simple CRUD pages, carrying all the infr needed in the querystring and the posted field values.
I've got a couple of apps made with some sort of framework built with classic asp.
This framework handles some CRUD stuff a little more complex than the examples I found.
Something like master-detail, filtering by example, paging, sorting and similars.
I have a controller class that it's just a finite state machine, that goes thru diferent states (like new, browse, filter, show, etc.), then performs the appropiate action depending on the event raised and finally retrieves the neede info to the calling page.
To achieve this I have several hidden inputs to keep the state of the web page (like current id, filter criterias, order criterias, previous state, previous event, well, you get the idea)
What do you think would be the finnest approach to achieve this kind of funcionality?
hidden inputs built in the view and used from the controller??? (I guess that would be the equivalent of what I'm doing right now in classi asp)
--
(added in response to tvanfosson)
basically, my question refers to the third category, the context-dependent setting (in respect to the other two categories I agree with you) the info I was storing in hidden fields to store them on the querystring, I guess that when you click on the "next page" you include everything you need to save in the querystring, right? so that piece of query string gets appended in each and every link that performns some kind of action...
I'm not sure, what are the advantages and disadvantages of using the querystring instead of hidden inputs???
I use different strategies depending on the character of the actual data. Things that are preferences, like default page size, I keep in a Preferences object (table) that is associated with the current logged in user and retrieve from there when needed.
Persistent settings associated with the current logon, like filter settings for a page, are stored in the user's session. Generally these are things that if a user sets them in the current session they should remain sticky. I think filter settings and visibility are like this. If I filter a list, navigate away from it to drill down into a particular item, then come back to the list, I want my filter settings to be reapplied -- so I make it part of the session.
Context-dependent settings -- like the current sort column or page number, are controlled using query parameters. Paging and sort controls (links) are built with the appropriate query parameters to "do the right thing" when clicked and pass any necessary query parameters to maintain or update the current context of the control. Using the query parameters allows you to use an HTTP GET, which is bookmarkable, rather than a POST. Using hidden form parameters makes it much harder for the user to save or enter a URL that takes them directly where they want to go. This is probably more useful for sorting than it is for paging, but the principle applies equally.