如何设置文本到Jqgrid下拉列表?

时间:2015-12-11 11:08:48

标签: javascript jquery asp.net-mvc jqgrid

我想在点击添加新按钮时为jqgrid下拉列表设置默认值。我的Jqgrid代码如下。

jQuery("#grdDrawdownSchedule").jqGrid({
        url: RootUrl + 'ECB/DDSGridData',
        datatype: 'json',
        mtype: 'POST',
        height: 130,
        colNames: ['id', 'Drawdown Date', 'Currency', 'Amount'],
        colModel: [
                    { name: 'id', index: 'id', width: 30, sorttype: "int", editable: false, hidden: true },
                    { name: 'DdDate', index: 'DdDate', width: 130, align: 'left', editable: true,
                        editoptions: {
                            readonly: 'readonly',
                            size: 10, maxlengh: 10,
                            dataInit: function (element) {
                                $(element).datepicker({ dateFormat: 'dd-M-yy', changeMonth: true,
                                    changeYear: true, constrainInput: false, showOn: 'both',
                                    buttonImage: RootUrl + 'Content/Images/grid_Calendar.png',
                                    buttonText: 'Show Calendar',
                                    buttonImageOnly: true
                                });
                            }
                        }
                    },
                    { name: 'CurrencyName', index: 'CurrencyName', width: 120, editable: true, edittype: "select" },
                    { name: 'Amount', index: 'Amount', align: "right", width: 120, editable: true,
                        editoptions: { size: "20", maxlength: "16", dataInit: function (element) {
                            $(element).keypress(function (e) {
                                $('#AvgMaturityLoan').val("0");
                                if (e.which != 8 && e.which != 0 && e.which != 46 && (e.which < 48 || e.which > 57)) {
                                    return false;
                                }
                                var charCode = (e.which) ? e.which : e.keyCode;
                                if (charCode == 46 && this.value.split('.').length > 1)
                                    return false;
                            });
                        }
                        }
                    },
        //{ name: 'tadte', index: 'tdate', width: 130, "editable": true, "sorttype": "date", editrules: { "date": true }, "editoptions": { "dataInit": "initDateEdit"} },                                               
                 ],
        loadComplete: function () {

            $("#grdDrawdownSchedule").setColProp('CurrencyName', { editoptions: { value: JSON.parse(Currencies)} });


        },
        cellEdit: true,
        rowNum: 100,
        rownumbers: true,
        cellsubmit: 'clientArray',
        caption: "Drawdown Schedule",
        multiselect: true,
        shrinkToFit: false, forceFit: true,
        width: 490,
        postData: {
            "lrnid": "0",
            "data": ""
        }

    });

我为网格添加新按钮

 $("#btnAddNewDrawdownSche").click(function () {
        if (ValidateRow($("#grdDrawdownSchedule"))) {
            var idAddRow = $("#grdDrawdownSchedule").getGridParam("reccount")
            emptyItem = [{ id: idAddRow + 1, DrawdownDate: "", Currency: "", amount: ""}];
            jQuery("#grdDrawdownSchedule").jqGrid('addRowData', 0, emptyItem);
            $("#grdDrawdownSchedule").jqGrid('setCell', rowId, 'CurrencyName', selectedLoanCurrencyValue);
        }
    });

当我单击Add New按钮时,最初我想将'INR'值设置为CurrencyName下拉列。那么如何将默认值设置为Jqgrid的列。

0 个答案:

没有答案