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:"[^]+"});
Related
Can i change the default behaviour of agSetColumnFilter of ag-grid. I can change the filter values by using values: paramter in filterParams. But Since Set Filter performs exact serarch with cell Value so can i update it to Contains search instead of Exact Search.
Yes, you can do it. Under column definition.
{
filter: 'agSetColumnFilter',
filterParams: {
values: ["custom1", "custom2"]
}
Also read about [https://www.ag-grid.com/javascript-grid-server-side-model-filtering/#example-set-filter] to load the values Async.
No, that's not supported. The whole point of the agSetColumnFilter is to match a (hopefully) small set of values contained in a column. If you have so many different values that you need a 'contains' filter, then the setFilter is probably not appropriate anyway.
That said, if you want custom behavior in a filter, that is not accommodated by a standard filter your best is probably to write your own custom filter. The documentation for custom filters can be found at https://www.ag-grid.com/javascript-grid-filter-component/#custom-filter-example
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.
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
I have a textbox with remote datasource for autocomplete(jquery) [not the plugin, the original one shown in jquery ui demos ]
How do I make sure user typed only what was in one of autocomplete suggestions and nothing of his own ?
The question is lacking specifics, but I will assume you mean validate on the client side since you referred explicitly to the auto complete plugin. This answer will have two parts. The first is the original answer, assuming one autocomplete plugin. The second is revised based on updates to the question.
1) Using http://docs.jquery.com/Plugins/Autocomplete
The best solution for this is the "mustMatch" option. Here is the API documentation.
If set to true, the autocompleter will only allow results that are presented by the backend. Note that illegal values result in an empty input box.
You should be able to use it in this way:
$("selector").autocomplete("url", {"mustMatch": true});
You can also validate the user input in some way in the "result" event. Here is a link: http://docs.jquery.com/Plugins/Autocomplete/result .
2) Using http://jqueryui.com/demos/autocomplete
There is no mustMatch option here. You could extend the plugin, or you could add something similar to what I mentioned for the other autocomplete plugin. Use the "change" event.
$( ".selector" ).autocomplete({
change: function(event, ui) { ... }
});
If you were using an array as a datasource, this would be more efficient. Since you are using a remote data source you would need to do another final query using ui.item to validate the user value. You can then allow or deny the default behavior.
In either case, the input should still be validated in some way on the server side. This is out of the scope of jQuery plugins.