可编辑单元格不工作的JEasy UI属性网格

时间:2016-09-02 06:05:50

标签: jquery jeasyui

我之前使用的是Datagrid而不是PropertyGrid,而且可编辑工作正常。

现在我需要对行进行分组,因此我必须将其从Datagrid更改为PropertyGrid。 现在,当我将其更改为PropertyGrid时,网格的可编辑功能无效。

这是我的代码示例:

$('#WBSResourcesGrid').propertygrid({
        title: 'Resources',
        url: '/CostEstimation/GetDataForResourceTable?wbsId=' + $('#hdnSelectedId').val(),
        view: groupview,
        groupFormatter: function (value, rows) {
            if (rows[0].WBRS_RST_TYPE=="E") {
                return 'Plant Machinery';
            }
            else if (rows[0].WBRS_RST_TYPE=="S") {
                return 'Sub Contract';
            }
            else if (rows[0].WBRS_RST_TYPE == "M") {
                return 'Material';
            }
            else if (rows[0].WBRS_RST_TYPE == "L") {
                return 'Human Resources';
            }
        },
        groupField: 'WBRS_RST_TYPE',
        fitColumns: true,
        singleSelect: true,
        idField: 'Id',
        method: 'POST',
        showFooter: "true",
        onSelect: function (index, row) {

            $('#WBSResourcesGrid').datagrid('showColumn', 'TempAccId');
            $('#WBSResourcesGrid').datagrid('beginEdit', index);
        },
        columns: [[
            { field: 'Id', title: 'Id', width: 60, hidden: true },
            { field: 'NameEn', title: '@label.NameEn', width: 180 },
             { field: 'WBRS_RST_TYPE', title: '@label.NameEn', width: 180, hidden: true },
            {
                field: 'NameAr', title: '@label.NameAr', width: 180,
                styler: function (value, row, index) {
                    return { class: 'arabic' };
                }
            },
            { field: 'AccNo', title: '@lblCommon.AccountNo', width: 180, hidden: false },
            {
                field: 'TempAccId', title: 'Select Acc No', width: 200, hidden: true,
                editor: {
                    type: 'combogrid',
                    options: {
                        panelWidth: 400,
                        textField: 'accountno',
                        valueField: 'accountno',
                        idField: 'budgetaccountsId',
                        required: true,
                        url: '/CostEstimation/GetWbsAccounts/',
                        columns: [[
                            { field: 'budgetaccountsId', title: 'Id', width: 150 },
                            { field: 'accountno', title: 'Account Name', width: 150 },
                            { field: 'accountname', title: 'Account Number', width: 150 },
                        ]],
                        onSelect: function (index, row) {
                            accountId = row.budgetaccountsId;
                        }


                    }
                },


            },//
            { field: 'Quantity', title: '@lblWBSResources.Quantity', width: 180, editor: 'text' },
            { field: 'UnitRate', title: '@lblWBSResources.UnitRate', width: 180, editor: 'text' },
            {
                field: 'TotalCost', title: '@lblWBSResources.TotalCost', width: 180,
                formatter: function (value, row, index) {
                    //  
                    if (row.TotalCost == "") {
                        var rows = $('#WBSResourcesGrid').datagrid('getRows');

                        var total = 0;
                        for (var i = 0; i < rows.length; i++) {

                            total += rows[i].Quantity * rows[i].UnitRate;
                        }

                        return total;
                    }
                    else {
                        return row.Quantity * row.UnitRate;
                    }

                }
            },
            { field: 'PredictedQty', title: 'Predicted Qty', width: 180, editor: 'text' },
            {
                field: 'action', title: 'Action', width: 80, align: 'center',
                formatter: function (value, row, index) {
                    if (row.TotalCost == "") {
                        return '';
                    }

                    if (row.editing) {
                        if (row.Id != -1) {
                            var s = '<a href="#" onclick="saverow(this,' + index + ')">Save</a> ';                                
                        } else {
                            var s = '<a href="#" onclick="addnewrow(this,' + index + ')">Save</a> ';
                            return s;
                        }
                        var c = '<a href="#" onclick="cancelrow(this)">Cancel</a>';
                        return s + c;
                    } else {
                        if (row.Id != -1) {
                            var e = '<a href="#" onclick="editrow(this)">Edit</a> ';
                            var d = '<a href="#" onclick="deleterow(this,' + index + ')">Delete</a>';
                            return e + d;
                        } else {
                            var s = '<a href="#" onclick="editrow(this)">Edit</a> ';
                            return s;
                        }
                    }
                }
            }
        ]],
        onBeforeEdit: function (index, row) {
            row.editing = true;
            updateActions(index);
        },
        onAfterEdit: function (index, row) {
            row.editing = false;
            updateActions(index);
        },
        onCancelEdit: function (index, row) {
            row.editing = false;
            updateActions(index);
        }
    }).datagrid('reloadFooter', [{ UnitRate: '@lblWBSResources.TotalPrice', TotalCost: '' }]);
}

0 个答案:

没有答案