日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Ext.grid.EditorGridPanel点击单元格改变数据,动态添加列

發(fā)布時間:2024/8/1 编程问答 118 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ext.grid.EditorGridPanel点击单元格改变数据,动态添加列 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文的重點

1、NumberField的listeners事件并不是很有效的驗證,那么我又重新寫了它的監(jiān)聽事件 2、grid的動態(tài)添加列的方法思路2-1:首先store是需要動態(tài)變化的2-2:其次cm也是要動態(tài)變化的2-3:grid 有個grid.reconfigure(store,cm);方法可以重新綁定cm和store

js代碼

var itemId = 0; /*根據(jù)接收的數(shù)據(jù)構(gòu)建cm和store ,這里的cm和store都是動態(tài)變化的*/initCm:function(){colMArray = [new Ext.grid.RowNumberer(),{header : "商品編號",width : 30,dataIndex : 'proCode',sortable : true},{header : "商品名稱",width : 40,dataIndex : 'proName',sortable : true},{header : "單位",width : 20,dataIndex : 'unitName',sortable : true},{header : "規(guī)格",width : 40,dataIndex : 'standard',sortable : true},{header : "凈價(點擊編輯)",width : 30,dataIndex : 'netPrice',sortable : true,editor : new Ext.form.NumberField({allowNegative : false,//是否允許負數(shù)allowDecimals : true,// 允許輸入小數(shù)maxValue : 1000000,nanText : '請輸入有效的凈價',// 無效數(shù)字提示minValue : 0,// 最小值listeners : {"focus" : function(field) {isvalid = true;},"valid" : function(field) {if (field.getValue() == "") {isvalid = false;}},"invalid" : function(field, msg) {isvalid = false;},"change" : function(field, newValue,oldValue) {if (isvalid) {Ext.Ajax.request({url : ctx+ '/priceManage_PriceManage_changeNetPrice',method : 'POST',params : {itemId : itemId,netPrice : newValue},success : function(response) {var res = Ext.util.JSON.decode(response.responseText);if (res.flag == false) {repair.error("數(shù)據(jù)更新失敗!");}},failure : Ext.emptyFn});} else {repair.error("輸入值非法!");}}}})},{header : "增值稅專用發(fā)票稅率(%)(點擊編輯)",width : 70,dataIndex : 'rate',sortable : true,editor : new Ext.form.NumberField({allowBlank : false,allowNegative : false,allowDecimals : false,// 允許輸入小數(shù)maxValue : 100,listeners : {"focus" : function(field) {isvalid = true;},"valid" : function(field) {if (field.getValue() == "") {isvalid = false;}},"invalid" : function(field, msg) {isvalid = false;},"change" : function(field, newValue,oldValue) {if (isvalid) {Ext.Ajax.request({url : ctx+ '/priceManage_PriceManage_changeRate',method : 'POST',params : {itemId : itemId,rate : field.getValue()},success : function(response) {var res = Ext.util.JSON.decode(response.responseText);if (res.flag == false) {repair.error("數(shù)據(jù)更新失敗!");}},failure : Ext.emptyFn});} else {repair.error("輸入值非法!");}}}})}, {header : "增值稅金",width : 30,dataIndex : 'netMoney',sortable : true}, {header : "含稅總價",width : 30,dataIndex : 'totalMoney',sortable : true}, {header : "上期含稅總價",width : 30,dataIndex : 'pretotalMoney',sortable : true}, {header : "幅度(%)",width : 30,dataIndex : 'extend',sortable : true}];Ext.Ajax.request({url : ctx + '/priceManage_PriceManage_getItemsByPriceCode',async : false,params : {priceCode : priceCode,},success : function(response, options) {var res = Ext.util.JSON.decode(response.responseText);listaskOrg = res.listaskOrg;storeRoot = res;totalCount = res.totalCount;myfields = [ // 接收的參數(shù){name : 'itemId'}, {name : 'proCode'}, {name : 'proName'}, {name : 'standard'}, {name : 'unitName'}, {name : 'netPrice'}, {name : 'rate'}, {name : 'netMoney'}, {name : 'totalMoney'}, {name : 'pretotalMoney'}, {name : 'extend'}, {name : 'pretotalMoney'} ];for ( var i = 0; i < listaskOrg.length; i++) {//對從后臺獲取的lostaskOrg進行遍歷,添加到myfields中-->storevar lista = listaskOrg[i];var askOrgCode = lista["askOrgCode"];var askOrgName = lista["askOrgName"];myaddfield = {name : askOrgCode};myfields.push(myaddfield);//并遍歷構(gòu)建colMArray---->cmvar nowColumn = {header : askOrgName,width : 40,dataIndex : askOrgCode};colMArray.push(nowColumn);}cm = new Ext.grid.ColumnModel(colMArray);}});store = new Ext.data.JsonStore({data : storeRoot,root : "root",autoLoad : true,totalProperty : "totalCount",fields : myfields});}, //我們要用到的EditorGridPanel grid = new Ext.grid.EditorGridPanel({id : 'grid',store : store,border : false,margins : '5 5 5 5',autoHeight : true,cm : cm,viewConfig : {forceFit : true},stripeRows : true,// 斑馬線效果loadMask : repair.gridLoadMaskConfig(),// 遮罩效果listeners : {"rowclick" : function(grid, rowIndex, e) {rowRecord = store.getAt(rowIndex);itemId = rowRecord.get("itemId");}}});

總結(jié)

以上是生活随笔為你收集整理的Ext.grid.EditorGridPanel点击单元格改变数据,动态添加列的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。