在可排序行中重新排序行之后调用Controller方法

时间:2015-05-25 11:54:03

标签: jquery asp.net-mvc-3 jquery-ui jqgrid

我想在jqgrid中执行行重排序功能。

我已经引用了trirand网站给出的可排序行示例,我可以上下移动行,

我们是否有任何方法可以重新排序行并为移动的行调用ajax事件?

这是我的网格:

jQuery(document).ready(function () {
    var pageWidth = $(window).width();
    var lastSel;
    $("#sortrows").setGridWidth(pageWidth);
    $('#sortrows').jqGrid('GridUnload');
    jQuery("#sortrows").jqGrid({            
        datatype: "local",
        mtype: "GET",
        hoverrows: false,
        jsonReader: { repeatitems: false, id: "Index" },
        ajaxGridOptions: { timeout: 30000 },
        colNames: PricelistHeaderColName,
        colModel: PricelistHeaderModel,
        id: 'Index',
        localReader: { id: 'Index' },
        prmNames: { id: "Index" },
        rowNum: 10,            
        rowList: [10, 20, 30],
        hidegrid: false,
        rownumbers: true,
        viewrecords: true,
        height: 'auto',
        width: pageWidth,
        scrollOffset: 0,
        gridview: true,
        autowidth:true,
        shrinkToFit: true,
        pager: '#psortrows',
        sortname: 'Description',
        autoencode: true,
        loadonce: true,
        ignoreCase: true,
        multiselect: false,
        viewrecords: true,
        sortorder: "asc",
        caption: "PriceList Headers",
        editurl: "../Header/Save",            

    });

    $('#sortrows').jqGrid('setLabel', 'Description', "Description", { 'text-align': 'left' });

    jQuery("#sortrows").jqGrid('navGrid', '#psortrows',
        {
            edit: false,
            add: false,
            del: false,

        });


    jQuery("#sortrows").jqGrid('inlineNav', '#psortrows',
        {
            add: true,
            addtext: "Add",
            addicon: "ui-icon-plus",
            edit: true,
            editicon: "ui-icon-pencil",
            edittext: "Edit",
            save: true,
            saveicon: "ui-icon-disk",
            savetext:"Save",
            cancel: true,
            cancelicon: "ui-icon-cancel",
            canceltext: "Cancel",
            search: true,
            searchtext: "Seaech",
            del: true,
            deltext: "Delete",
            delicon : "ui-icon-delete",

            // additional parameters below:
            editParams: inlineEditOptions,
            addParams: { addRowParams: inlineAddOptions }                

        });

    jQuery("#sortrows").jqGrid('sortableRows', { items: '.jqgrow:not(.unsortable)' });

    $('#sortrows').jqGrid('filterToolbar', { searchOnEnter: false, enableClear: false, defaultSearch: "cn", stringResult: true });

    //var myData = $('#sortrows').jqGrid('getDataIDs');        
    for (var i = 0; i < myData.length; i++) {            
        //jQuery("#sortrows").addRowData(myData[i].Code, myData[i]);
        $("#sortrows").jqGrid('addRowData', i + 1, myData[i]);

    }
    var recordCount = $("#sortrows").jqGrid('getGridParam', 'reccount');
    console.log(recordCount);

});

在重新排序行之后,我需要调用控制器操作来保存数据库更改。我找不到解决方案。请帮助我............

0 个答案:

没有答案