jqGrid filter representation object - javascript

Is there a way to get an object from jqGrid that represents the filter parameters that were applied to the current result set? If yes, is there a way to later apply this object to the grid?

I usually read the postData param of the grid grid.getGridParam('postData');
it has a string property called filters which contains the current filter of the grid (it's a json text).
you can modify it and then apply it to the grid using grid.setGridParam('postData', postData);

Related

Sorting agGrid By a GroupBy Autocolumn When Saving/Restoring Column State

In our application using agGrid, we allow the user to provide a default sort which is then passed into our screen upon opening, converted into an agGrid sort model, and then passed to agGrid to set the sort model (api.setSortModel).
Since the columns on this screen are known, it is easy to specify something like CCYID ASC, ENTITYID DESC and have it be directly translated into a sort model.
However the problem is that some of these screens use row grouping. In this particular instance we're grouping by CCYID. The actual CCYID column is then set to hidden and the groupby values are displayed in an agGrid automatically generated column (the autocolumn I believe?)
However, I still want to sort by CCYID, but as it is a hidden column, no sort will take. Is there a way to specify the auto column by name such that it could be used in defining a sort model? Does it have a constant name, something like "AUTOCOLUMN0" or some such?

Data transformation for KendoUI grid

I have a JSON data structure that I need to display in Kendo UI grid. The data is something like this
[
{"ObjType": {"Key1":"Value1", "Key2":"Value2", "Key3":["1234","45223"]}},
{"ObjType": {"Key1":"Value3", "Key2":"Value4", "Key3":["1234","45223"]}},
{"ObjType": {"Key1":"Value5", "Key2":"Value6", "Key3":["1234","45223"]}}
]
Kendo UI expects an array of Key/Value pairs or defined columns with array of arrays of values. What's the best way to transform this into something that the grid can understand?
Or maybe there is a way in Kendo grid to specify where to get the data from. The array in Key3 can be converted into string.
The schemas of the data can change - for different ObjType there will be different keys and different number of them, but the structure is pretty much the same - string key and string or array of strings value. And the ObjType stays the same through the document, but can change when we read a different document.
The Kendo UI DataSource schema has a parse configuration option, which allows you to tweak the data response before the DataSource instance handles it.
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.parse

How to get all the values from a FilteringSelect in dojo?

I have a FilteringSelect called select, and the values are being added from different places. At one point of time, I wanted to access all the values from the FilteringSelect.
In order to get a single value, I can use select.get('value'). But I wanted to have all the values in an array. In jQuery, we can do something like below,
var values = $('#select').val(); //returns an array
So, how to do the same in dojo?
If you want to get the list of 'options' in the FilteringSelect you can inspect the data element of the store.
e.g.
define([dijit/registry'], function(registry) {
// this will return an array of options
registry.byId('select').get('store').data;
});
happy coding.

How to compare Two data stores in Dojo

I have two data store of type dojo.data.ItemFileReadStore.One of the data store having old data and other one having new data.How can i compare these two data stores?
I call the fetch method on both of the stores and did a compare but didn't work for me.
IF a same item can be in two stores, then you could fetch all items from one store, on Complete, foreach item, otherStore.isItem(someItem) which will return a boolean :)
Have you tried that?
The format used by ItemFileReadStore is not a requirement of the dojo.data API. The
format it uses is designed to work well for the specific situations
ItemFileReadStore is used for, which are moderately sized data sets that can be easily
represented in a JavaScript Object tree.
Structure of Input Data Format
{
"label": "some attribute", // Optional attribute used to indicate which attribute on
an item should act as a human-readable label for display purposes.
"identifier": "some attribute", // Optional attribute used to indicate which
attribute on an item acts as a unique identifier for that item. If it is not defined,
then the ItemFileReadStore will simply number the items and use that number as a
unique index to the item.
"items:" [ // The array of JavaScript objects that act as the root items of the data
store
{ /* Some set of name/value attributes */ },
{ /* ... */ },
...
]
}
solution 1: in our application we have used this method:
dojo.require("dojo.json");
_equal: function(objA, objB) {
return dojo.json.stringify(objA) === dojo.json.stringify(objB);
}
the data inside objects should also have the same order, otherwise comparison will fail.
solution 2: but in dojo 1.8 they have introduced dojox/mvc/equals function.
it compares two given objects.
please also consider using dojo/store instead of deprecated dojo/data

How correct use terelik getGridMasterTableView().filter() methot on javascript on client side?

I use telerik radGriD funcrion on javascript client-side:
getGridMasterTableView().get_filterExpressions().clear(); - clear array of filter expression.
getGridMasterTableView().filter(fieldName, strData, GetExpressionValue(fieldExpression)); - add elenent in array filter expression.
when I call this getGridMasterTableView().filter(fieldName, strData, GetExpressionValue(fieldExpression)) method two times, when fieldName allways the same, the method getGridMasterTableView().get_filterExpressions() in watch shows that it simply rewrites element but I need that it add new element. How resolve it?
Are you attempting to apply two filters on the same column? From the sound of things you are filtering once, and then trying to filter that same result once more. You can only have one filter on a column at a time, so when you call the filter() method the second time it just removes the old filter and filters according to the last filter() call.
For more information regarding client-side filtering I recommend looking over this documentation article.

Categories

Resources