开发者

saving row instead of restoring the data

I want to save the data instead of restore it when I select another row. How I can accomplish that?

I've been testing with this code without any results:

    onSelectRow: function(row_id) { 
        if(row_id && row_id !== last_selected) {
            /*
             * Save row.
             */
            $('#grid').jqGrid('saveRow', ((last_selected !== undefined)?last_selected:row_id) , true, function() {/* OnEditFunction */}, function(response) {
                /* SuccessFunction */
                var row_to_save = ((last_selected !== undefined)?last_selected:row_id);

                success_function(row_to_save, response);

                }, 'http://some_url.com');

            last_selected = row_id;
        }   

        /*
         * Edit row.
         */
        $('grid').jqGrid('edi开发者_Go百科tRow', row_id, true, function() {/* OnEditFunction */}, function(response) {
            /* SuccessFunction */
            success_function(row_id, response);

            }, 'http://some_url.com'); 
    },

It could be great if I could be able to fire a success function before the row is saved successfully, so I can show a notification message.

Thanks in advance.


I suppose that you have the problem because one small error in your current implementation of the succesfunc which you use in saveRow or editRow. The method editRow just forward the succesfunc parameter to saveRow, so you will find the detailed description of the succesfunc parameter in the documentation of the saveRow. You can read the following:

succesfunc: if defined, this function is called immediately after the request is successful. This function is passed the data returned from the server. Depending on the data from server; this function should return true or false.

So you should at least include return true; as the last statement of your implementation of the succesfunc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜