1

I have one jsp page with jqgrid I want to pass that grid data to action class.I am editing jqgrid data using cellEdit and now i want to pass this new data to action class to update this data in database.How can i pass the jqgrid data from jsp to action class?

 <sjg:grid id="gridtable" caption=" " dataType="json" 
                href="%{listurl}"
                gridModel="listMS_AUTONUMBER"
                            cellEdit="true"
                    cellurl="%{cellediturl}">

<sjg:gridColumn frozen="false"  name="autonumberCd" index="autonumberCd" title="%{getText('autonumber.autonumbercode')}"
                    sortable="true" search="true" editable="true" key="true" editoptions="{maxlength :2}"
                    editrules="{required:true,custom:true,custom_func:validateCapitalAlphanumeric}" formatter="String"  formoptions="{elmsuffix:'  *'}"/>     

                <sjg:gridColumn name="autonumberNm" index="autonumberNm" title="%{getText('autonumber.autonumbername')}"
                    sortable="true" editable="true" edittype="text" editrules="{required:true}" editoptions="{maxlength :10}" formoptions="{elmsuffix:'  *'}" />        

                <sjg:gridColumn name="nextAutonumber" index="nextAutonumber" title="%{getText('autonumber.nextautonumber')}"
                    sortable="true" editable="true" edittype="text" editrules="{required:true,custom:true,custom_func:validateNumericOnly}" editoptions="{maxlength :10}" align="right" formoptions="{elmsuffix:'  *'}" />                      
            </sjg:grid>

This is my jqgrid in which listMS_AUTONUMBER is list which retrieves value from database and coming from another action class.

1
  • what kind of format are you using in the jqgrid? json? You should post code, so people can understand you better Commented Nov 8, 2012 at 10:48

1 Answer 1

2

To pass the jqgrid data from jsp to action class i am using json as follows:

var data=jQuery("#gridtable").jqGrid('getRowData');      //this method gets all the data from grid
var postData = JSON.stringify(data);          //using json stringify convert the data in string format
alert(postData);

using alert I am displaying data of jqgrid in string format.

After that I am sending this data to action class through AJAX as follows:

$.ajax({
       type: "Get",
    url: "action_name?AutoList="+postData,
    data : {
           jgGridData: postData,
        },
    dataType:"json",
    contentType: "application/json; charset=utf-8",
});

After this in action class, converting this String to json format as follows:

JSONArray outerArray = (JSONArray) JSONSerializer.toJSON(AutoList); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.