Meraj
Meraj

Reputation: 426

jqgrid saving records for inline editing

in jqgrid for inline editing when we click the save icon, ** internally it calls the saveRow method, but i want to call my custom method where i will implement my save logic as well calling to controller method.**

i used below code for grid.

var grid = jQuery("#list5").jqGrid({
            url: '/home1/GetUserData',

                datatype: "json",
                mtype: "POST",
                colNames: ['Code', 'LoginID', 'Emailid', 'CreateDate', 'PostalCode', 'Mobile'],
                colModel: [
                            {name: 'Code', index: 'Code', width: '16%', editable: true, sortable: true },
                            { name: 'LoginID', index: 'LoginID', width: '16%', editable: true, sortable: true },
                            { name: 'Emailid', index: 'Emailid', width: '16%', editable: true, 

        sortable: true },
                              ],
                    rowNum: 10,
                    height: '100%',
                    scrollOffset: 0,
                    rowList: 10,
                    shrinkToFit: true,
                    pager: $("#pager2"),
                    editurl: "/home1/EditUserData",
                    caption: "Simple data manipulation"
                });
                jQuery("#list5").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: true, search: false, refresh: false }, {}, {}, { url: '/home1/DeleteUserData' });
                jQuery('#list5').jqGrid('inlineNav', '#pager2', { edit: true, add: true},
                });
            });

so please anyone let me know how to implement it.

Upvotes: 0

Views: 7637

Answers (1)

Oleg
Oleg

Reputation: 221997

I don't really understand your requirements. saveRow has a lot of customization possibilities. You can rename all parameters which will be sent to the server using prmNames option of jqGrid. Using extraparam parameter of saveRow you can specify additional information which can be sent to the server. The callback serializeRowData can be used to implement your custom serialization. For example you can convert the data to JSON. Using aftersavefunc you can make some custom actions after the data will be successfully saved on the server. So I recommend you use the features instead of implementing your custom saveRow method.

UPDATED: If you want to have navigator icon which uses your custom saveRow you should don't add "Save" button by inlineNav. You can use save: false option of inlineNav. Then you can just use navButtonAdd and add your custom icon which look exactly like original "Save" button and make call of your "custom saveRow" in the onClickButton callback.

Upvotes: 1

Related Questions