I'm using Zend_Framework and have created a Zend_Plugin to register a jqGrid _search call and store the filters array into a Zend_Session_Namespace object.
When the user goes to another page and comes back to the original jqGrid instance, my controller will build the jqGrid object with the following snippet after the jqGrid construction:
$(“#gridid”).jqGrid(“setGridParam”, { sortname: “somevar”, sortorder: “ASC”, page: 1, rowNum: 20, search: true, postData: { “filters”: {“groupOp”:”AND”,”rules”:[{“field”:”somevar”,”op”:”bw”,”data”:”test”},{“field”:”somevar2″,”op”:”eq”,”data”:”test2″}]}}}).trigger(“reloadGrid”);
Because I am storing these filters in a session my controller/model will perform the saved search on the database. When I open the advanced search modal it shows the appropriate filters that were stored/loaded except that the data element (form element) is not working correctly for those fields that are stype: “select” with a dataURL option. They are just text boxes with the select.val() and not select.text(), so it is showing a lot of primary_keys instead of the textual description of the selection. When I modify that existing filter by selecting another field and going back, the data (value) item still does not update to the dynamic select menu of items but stays a text box.
I figured out how to get rid of the default filter item (when loading saved filters) by adding the following to the searchGrid:
afterShowSearch:function(){ $(“.sf”).last().empty().remove();}
I've also had to manually attempt to update the $(“#t_gridid”) (top bar) for the “Search Results:” component…
jQuery(“#gridid”).setColProp(“somevar”,{searchoptions:{defaultValue:”someval”}});
var GText = jQuery(“#gridid”).getColProp(“somevar”);
$(“#t_gridid”).append(” “+GText.label+” “);
$(“#t_gridid”).append(“'.$this->_op.'”);
$(“#t_dynagrid”).append(“”'.$this->_val.'”;”);
However this also does not show the full text representation of the “op” or the “val/data”. It shows primary_keys and not the searchGrids select.text representation.
There has got to be a better way to save and load search filters.
Any ideas?
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top