JQGrid单元格中的下拉列表

时间:2015-02-26 15:31:36

标签: jquery asp.net asp.net-mvc-4 jqgrid asp.net-mvc-5

我有一个jQGrid显示像这样的国家/地区列表

function ShowCountry() {
    try {      
        $("#gridCountry").jqGrid({
            url: "/Master/GetAllCountry",
            datatype: "json",
            mtype: "Get",
            colNames: [ 'CountryID', 'Country Name', 'Abbreviation', 'Active', 'Last Modified Date','Select'],
            colModel: [
            { key: true, hidden: false, name: 'CountryID', index: 'CountryID' },
            { key: false, hidden: false, name: 'CountryName', index: 'CountryName'},
            { key: false, name: 'Abbreviation', index: 'Abbreviation' },
            {
                key: false, name: 'IsActive', index: 'IsActive', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" },
                formatter: "checkbox", formatoptions: { disabled: true }, align: 'center'
            },
            { key: false, name: 'LastModifiedDate', index: 'LastModifiedDate', formatter: 'date', formatoption: { newformat: 'd/m/Y' } },
            { name: 'Select', index: 'Select', sortable: false, formatter: DisplaySelectList }
            ],
            pager: "#divPager",
            rowNum: 10,
            rowList: [10, 20, 30, 40],
            height: "100%",
            viewrecords: true,
            caption: "Country List",
            emptyrecords: "no record to display",
            jsonReader: {
                root: 'rows',
                page: 'page',
                total: 'total',
                records: "records",
                repeatitems: false,
                id: '0'
            },
            autowidth: true,
            multiselect: false,
            loadonce: true
        }).navGrid('#divPager', { edit: true, add: false, del: false, search: false, refresh: true },
        {
            zIndex: 100,
            url: '/Master/UpdateCountry',
            closeonEscape: true,
            closeAfterEdit: true,
            recreateForm: true,
            afterComplete: function (response) {
                if (response.responseText) {
                    // alert(response.responseText);
                    document.getElementById('divAlert').style.display = 'block';
                    document.getElementById('divError').innerHTML = response.responseText;
                    //divError
                }
            }
        });
    }
    catch (err) {
        document.getElementById('divAlert').style.display = 'block';
        document.getElementById('divError').innerHTML = err;
    }
};

function DisplaySelectList(cellvalue, options, rowObject) {
    var edit = "<select name='gridDropdown'></select>";
    return edit;
}

我想绑定此网格的最后一列(命名选择)的下拉列表,我使用DisplaySelectList作为格式化程序方法。

这显示下拉列表,但我想使用Id填充下拉列表中的一些数据。我写了onload for dropdown但是徒劳无功。

请指导我这个

0 个答案:

没有答案