修改Ext grid 单元格

View Code
 1     this.AddGridColumns = [
2 { text: "产品Id", width: 150, dataIndex: 'MaterialId', sortable: false, hidden: true },
3 { text: "产品名称", flex: 1, dataIndex: "MaterialName", sortable: false },
4 { text: "数量(千克)", width: 150, sortable: false, dataIndex: 'BasicCount', renderer: DateRenderer, editor: { xtype: 'numberfield', minValue: 0} },
5 { text: "数量", width: 150, sortable: false, dataIndex: 'CommodityCount', renderer: DateRenderer, editor: { xtype: 'numberfield', minValue: 0} },
6 { text: "单位", sortable: false, header: '单位数量', dataIndex: 'Unit', width: 100, field: { xtype: 'combobox', typeAhead: true, triggerAction: 'all', editable: false, selectOnTab: true, store: [['微克', '微克'], ['毫克', '毫克'], ['克', '克'], ['千克', '千克'], ['吨', '吨']], lazyRender: true, listClass: 'x-combo-list-small'}}];
7 this.AddGridFields = [{ name: "MaterialId" }, { name: "MaterialName" }, { name: "BasicCount" }, { name: "CommodityCount" }, { name: "Unit"}];
8 this.AddGridStore = Ext.create('Ext.data.Store', {
9 fields: myThis.AddGridFields,
10 autoLoad: true,
11 proxy: {
12 extraParams: {
13 operate: 'LoadData_TempPProductOrder',
14 str: ''
15 },
16 type: 'ajax',
17 url: myThis.url,
18 reader: {
19 type: 'json',
20 root: 'rows'
21 }
22 },
23 fields: myThis.AddGridFields,
24 remoteSort: true
25 });
26 this.AddGrid = Ext.create("Ext.grid.Panel", {
27 autoScorll: true,
28 height: 298,
29 tbar: [{ text: '添加产品', iconCls: 'icon-add',
30 handler: function () {
31 myThis.popupWindowMaterialMessage.show();
32 }
33 }, { text: '删除产品', iconCls: 'icon-delete',
34 handler: function () {
35 var selrows = myThis.AddGrid.getSelectionModel().getSelection();
36 myThis.AddGridStore.remove(selrows);
37 var nodes = myThis.AddGrid.getView().getNodes();
38 var tempArr = [];
39 if (nodes.length != 0) {
40 for (var i = 0; i < nodes.length; i++) {
41 tempArr.push(nodes[i].children[1].children[0].innerHTML);
42 }
43 myThis.PProductOrderIDS_Temp = tempArr.join(',');
44 } else if (nodes.length == 0) {
45 myThis.PProductOrderIDS_Temp = '';
46 }
47 }
48 }],
49 plugins: [
50 Ext.create('Ext.grid.plugin.CellEditing', {
51 clicksToEdit: 2
52 })
53 ],
54 iconCls: 'icon-grid',
55 store: myThis.AddGridStore,
56 selModel: new Ext.selection.CheckboxModel(),
57 columns: myThis.AddGridColumns
58 });
59 myThis.AddGrid.on('edit', function (editor, e) {
60 if (e.value == null || e.value == undefined || e.value == "") {
61 e.record.set("BasicCount", 1);
62 e.record.set("CommodityCount", 1);
63 e.record.commit();
64 myThis.AddGrid.getView().refresh();
65 Ext.Msg.alert('提示', '请输入正确的数量!');
66 }
67 else {
68 ////BasicCount CommodityCount Unit
69 var nodes = myThis.AddGrid.getView().getNodes();
70 for (var i = 0; i < nodes.length; i++) {
71
72 var unitNum =myThis.GetUnitNum(e.record.data.Unit);
73 debugger
74 var CommodityCount = e.record.data.CommodityCount;
75
76 var BasicCount = CommodityCount/ unitNum ;
77 e.record.set("BasicCount", BasicCount);
78 e.record.set("CommodityCount", CommodityCount);
79 e.record.commit();
80 myThis.AddGrid.getView().refresh();
81 }
82 }
83
84 });

转载于:https://www.cnblogs.com/sunjinpeng/archive/2011/12/12/2284725.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值