0

I am implementing jqgrid using struts2-jqgrid-plugin. My problem is when I change a value of hidden field in form-element ,the updated values are not reflected when i post these hidden field with my jqgrid.

My form with jqgrid

<form name="adminFrm" id="adminFrm">
<div>
<s:url var="remoteurl" action="adminJsontable">
    </s:url>
    <sjg:grid
        id="gridtable"
        caption="Issue-Summary"
        dataType="json"
        href="%{remoteurl}"
        pager="true"
        gridModel="finalGridModel"
        rowList="10,20,25,30"
        rowNum="10"
        rownumbers="true"
        width="1250"
        loadingText="Dashboard is being Loaded..."
        formIds="adminFrm" // here I am sending all form-elements
        gridview="true"   
     >
        <sjg:gridColumn  name="issue_id"  id="issueId"   index="id" title="Issue-ID" formatter="integer" formatoptions="{thousandsSeparator: ''}"  sortable="false" width="100"/>
        <sjg:gridColumn name="issue_status"  index="issue_status" title="Current Status" search="true" searchoptions="{value:':Any;Completed:Completed;Assigned:Assigned;Denied:Denied'}"             searchtype="select"/>

    </sjg:grid>

</div>
<s:hidden name="hidden_field" id="hidden_field" value="123456"></s:hidden>   
  </form>

Here i am trying to update the hidden field value on some event

function x()
{
$("#hidden_field").val("Value changed");
}

But when jqgrid reloads, it still posting the previous value of hidden field i.e. 12345 instead updated value. I checked the hidden field using firebug ,that is also showing that the value of hidden field has been changed then why jqgrid is still posting the previous value to server(which i checked via firebug) which does not exist on page. how to solve this problem. for details you can refer this post issue with ajax call on paging in jqgrid

Community
  • 1
  • 1
arvin_codeHunk
  • 2,328
  • 8
  • 32
  • 47
  • Are you seeing the hidden value being posted to the server? – Mark Mar 20 '13 at 10:33
  • Where would the `hidden_field` be set on grid load? – Mark Mar 20 '13 at 10:35
  • @Mark yes this hidden_field is getting posted over server, i have checked my console as well as firebug also, where hidden_field is getting updated but when jqgrid reload ,it posting the old value. – arvin_codeHunk Mar 20 '13 at 10:40
  • And where are you passing the data down with the jqGrid? userData? – Mark Mar 20 '13 at 10:44
  • @Mark I am sending hidden_field using tag "formids" (check my grid) , which concatenate all form elements with url when its reload or call the action. – arvin_codeHunk Mar 20 '13 at 10:44

1 Answers1

0

Ok, I think I understand (I don't do struts). The value would be set when the jqGrid is built and you need to update it when it goes to reload as it is seeing the value that was set when the jqGrid was initialized.

Edit: Try resetting the grid parameter after the hidden field is changed via:

$('#gridName').jqGrid('setGridParam', { formIds: 'adminFrm').trigger('reloadGrid', [{ page: 1}]);
Mark
  • 3,123
  • 4
  • 20
  • 31
  • Is there a reason you use this `formIds` method instead of passing in extra data with the post via `postData`? – Mark Mar 20 '13 at 10:52
  • Reset the grid `formIds` property after the hidden field edit and it probably will pick up the new value. – Mark Mar 20 '13 at 10:54
  • reason behind this was ,somehow i was unable to use postData, u can say either its limitation for me bcoz of using struts2-jqgrid or i dont know the basics of jqgrid, that is why i am using this formids. – arvin_codeHunk Mar 20 '13 at 10:58
  • well well , how can i reset formIds property using jquery or javascript. – arvin_codeHunk Mar 20 '13 at 11:00
  • Well I read through the post Oleg put up but I would be shocked that `postData` functionality is different for a different flavor of jqGrid. Just to be clear, you are using the paid server side version of jqGrid and not the javascript/jQuery extension of jqGrid? – Mark Mar 20 '13 at 11:00
  • i accept it , may be there is a possibility that i dont know how exactly postData works? – arvin_codeHunk Mar 20 '13 at 11:02
  • I would think you would easily find a number of example using jqGrid with a Stuts backend with the Javascript plugin to jQuery. Or even the paid server side verion with Java. – Mark Mar 20 '13 at 11:04
  • well, there is a very less documentation regarding the struts-jqgrid as well as examples are very few and not well explained . – arvin_codeHunk Mar 20 '13 at 11:09
  • setting 'formIds' is not working , i am still facing the same problem. – arvin_codeHunk Mar 21 '13 at 10:29
  • Wonky... perhaps time for a step back and to be clear about why you are doing what you are doing and if you understand the tools you are using. If you were to use a struts backend with the regular Javascript extension for jQery version of jqGrid I know you could use postData to pass in your extra information. – Mark Mar 21 '13 at 11:36
  • u still did'nt get it, I am asking why it is posting the old value but not the updated value – arvin_codeHunk Mar 21 '13 at 12:24
  • I think this post is having some kind of useful info http://stackoverflow.com/questions/4996538/set-jqgrid-edit-options-via-setgridparam ,i did'nt get it but seems it should work – arvin_codeHunk Mar 21 '13 at 12:57
  • Did you get your problem fixed? Did this help? If so please mark as correct – Mark Apr 16 '13 at 11:46