簡體   English   中英

添加jqgrid后如何選擇插入行的位置?

[英]How to select and position on inserted row after add in jqgrid?

我有一個很好的jqgrid。 但是,添加后,我想選擇自己並放置在插入的行上。 我希望插入的行被正確排序並放置在jqgrid中。

目前,我僅設法選擇了插入的行,但在網格中未正確對其進行排序。 插入的行顯示在我當前所在的任何頁面的頂部。

這是我的代碼示例,帶有create函數,該函數在jqgrid中插入新行。

$(document).ready(function () {
        $('#jqgProducts').jqGrid({
            //url from wich data should be requested
            url: '@Url.Action("DynamicGridData")',


            //type of data
            datatype: 'json',
            mytype: 'POST',
            //url access method type
            //jsonReader:{repeatitems : false, id: "cSfPT"},
            //columns names
            colNames: ['Šifra pošte', 'Naziv pošte', 'Napomena'],
            //columns model
            colModel: [
                        { name: 'cSfPT', index: 'cSfPT', align: 'left', width: '100px', key: true, editable: true, search: true

                         },

                        { name: 'cNzPt', index: 'cNzPt', align: 'left', width: '200px', editable: true, edittype: 'text',
                             },

                        { name: 'cNapomena', index: 'cNapomena', align: 'left', width: '400px', 

                         editrules: { required: false} }
                      ],
            //pager for grid
            pager: '#jqgpProducts',
            //number of rows per page
            rowNum: 10,
            //initial sorting column
            sortname: 'cSfPT',
            //initial sorting direction
            sortorder: 'asc',
            //we want to display total records count
            viewrecords: true,
            //grid height
            height: '300px',
            width : 1000,
            rownumbers: true,
            //scroll: true,
            cellEdit:true,
            cellurl: 'Edit',


            loadComplete: function () {
                if (idToSelect) {
                $(this).jqGrid('setSelection', idToSelect);
                //$("#" + $.jgrid.jqID(idToSelect)).effect("highlight", {}, 3000);
                idToSelect = undefined;
                }
            }

 $('#jqgProducts').jqGrid('navGrid', '#jqgpProducts',
            { add: true,
              del: true,
              edit:true, 
              search: true

               },

{width: '450', url: '@Url.Action("Create")', closeAfterAdd: true, 

            closeAfterEdit: true,

            reloadAfterSubmit: false,

            afterSubmit: function (response) {
                return [true, '', response.responseText];
            },


            addedrow: "last", // add new row at the end of grid

             afterComplete: function (response, postdata) {

                var gridId = this.gbox.substr(6);

                $('#' + gridId).jqGrid('setSelection', postdata.id);
             },




            afterSubmit: function (response) {

            idToSelect = response.responseText;
            return [true, '', response.responseText];
            }

       };
      );
    });

我將不勝感激任何幫助。

客戶端可以設置:

sortname: 'yourSortingColum'
sortorder: 'asc' || sortorder:'desc'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM