开发者

jqGrid '_search' parameter not being set in URL

开发者 https://www.devze.com 2023-03-14 13:14 出处:网络
I have the following code: $(\"#perform_search\").click(function() { var postdata = $(\"#translationsList\").jqGrid(\'getGridParam\',\'postData\');

I have the following code:

$("#perform_search").click(function() {    
  var postdata = $("#translationsList").jqGrid('getGridParam','postData');
  postdata._search = true;
  postdata.searchString = $("#auto_complete_search").val();
  console.log('postdata._search: ' + postdata._search);
  jQuery("#translationsList").trigger("reloadGrid", [{page:1}]);
});

When I click on the button with ID perform_search the resulting URL is below, and the value searchString=hello is pulled from a text field with an id of auto_complete_search:

[domainname]/translations_feed.php?language_cd=EN&_search=false&nd=1308754288459&rows=20&page=1&sidx=phrase&sord=asc&searchString=hello

... and what's supposed to happen is that the URL string has _search=true, but as you can see from the sample URL, the value being passed is _search=false NOTE: line 5, where I output the value of postdata._search to the console, the console shows postdata._search: true as expected, so that appears to be working as expected.

Seems like all other params are passing through just fine.

UPDATE

Seems that, if I first use the built-in search button (the little magnifying glass icon in jqGrid), that is sets the "_search=true" param correctly - and after that my button works fine. Not sure what the connection between to the two is, but essentially it seems as if my param is still 开发者_StackOverflow社区being ignored either way. For example, if I do a search via the magnifying glass, and change my javascript so that LINE 5 reads postdata._search = false it passes _search=true (in other words, LINE 5 seems to be ignored completely).

Wondering if I'm simply setting the wrong variable on postdata


I answered an already closed question like yours. The problem is that you should be setting the search parameter on the jqGrid itself, and not trying to alter the postData in this way.

In other words, to set _search as true you should set search parameter of jqGrid to true and not set any properties of postData directly. Similarly, you should not set page parameter of postData. Instead use the rowNum parameter.

So, your code should be much simpler:

$("#perform_search").click(function() {    
  $("#translationsList").jqGrid('setGridParam', { search: true, postData: { searchString:$("#auto_complete_search").val() } });
  jQuery("#translationsList").trigger("reloadGrid", [{page:1}]);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消