extjs单行编辑RowEditing修改后台部分的东西后前端写法

function product_row_cost(field){ //当有focus时,被监听调用的方法,取所在行数
product_grid_row=product_info_grid.getSelectionModel().getSelection();
}


function product_return_sku_no(field,e){
      if(e.getKey()==39 || e.getKey()==13) //当按下键keypress时,监听回车和向右的按钮
      {
      Ext.getCmp('cname_row').focus(true,true);    //会直接进入下一个右侧输入框
    }
}

function product_return_cname(field,e){

if(e.getKey()==37){ //按下向左的按钮
      Ext.getCmp('sku_no_row').focus(true,true);
    }
      else
      if(e.getKey()==39 || e.getKey()==13)
      {
      Ext.getCmp('ename_row').focus(true,true);
    }
}

function product_add_sku_no(field){ //当焦点移开时,保存数据
gridRowEditing.grid.editingPlugin.completeEdit();
Ext.Ajax.request( 
 {
url :'./data/node_tbl_product_info.php?t=11',
method :"post",
params
  {
  cpid : product_grid_row[0].get("cpid"),
sku_no : field.getValue()
   },
  success : function(d) 
  {
obj = Ext.JSON.decode(d.responseText);
if(obj.success == false)
{
alert(obj.message);
}
}
 });
}


var gridRowEditing = Ext.create('Ext.grid.plugin.RowEditing',{ //单元格编辑插件    CellEditing   单行编辑插件 RowEditing
clicksToEdit:1 //点击一次编辑
});

var sm = Ext.create('Ext.selection.CheckboxModel');
 var product_info_grid = Ext.createWidget('gridpanel', {
    title:'合同产品信息表',
    style:"text-align:center;",
    store:product_info_grid_store,
    selModel: sm,
    width: 980,
    height:535,
    loadMask: true,
    stripeRows: true,
    frame:true,
    stripeRows: true,
    frame:true,
    plugins:[gridRowEditing], //调用编辑插件
    features:[{
      ftype:'summary' //ext.grid.feature.Summary表格
   }],
    columns: [
          {
             xtype: 'rownumberer',
             width: 20,
             sortable: false
          },
          {
             text: '产品信息ID',
             dataIndex: 'cpid',
             flex: 1,
             hidden: true,
             sortable: false
         },
         {
             text: '合同ID',
             width: 70,
             dataIndex: 'contract_id',
             sortable: false
         },
         {
             text: '产品编号',
             dataIndex: 'sku_no',
             width: 130,
             sortable: false,
             editor:{ //编辑模式一定要有editor这个
              xtype:'textfield',  //文本输入框
              enableKeyEvents:true, //监听键盘按钮要有这个
              listeners : { //监听
              focus : product_row_cost, //聚焦时调用product_row_cost函数
              keypress : product_return_sku_no, //按下键盘时监听
              blur : product_add_sku_no //焦点离开时调用product_add_sku_no函数
             },
              id:'sku_no_row', //监听键盘时,聚焦到哪个输入框的ID
              allowBlank:false
             }
         },
         {
             text: '品牌',
             dataIndex: 'ename',
             width: 100,
             selectOnFocus :true,  
             editor:{
       xtype:'combo', //下拉框
        allowBlank:false,
        forceSelection: true,
triggerAction : 'all',
editable :false,
enableKeyEvents:true,
            listeners : {
            focus : product_row_cost,
            keypress : product_return_ename,
            blur : product_add_ename
          },
            id:'ename_row',
store : combo_Product_brand_one,    
queryMode : 'remote',   
emptyText :'请选择...',  //提示信息  
displayField : 'Name',    
valueField : 'Name'
 }
         },
          {
             text: '销售小计',
             dataIndex: 'price2',
             width: 130,
             sortable: false,
             xtype:'numbercolumn',
          format:'¥0.00',
          align:'right',
             summaryType:'sum',        
             summaryRenderer:function(value,summaryData,dataIndex)
             {             
  price2_all=value.toFixed(2);
return "<font size='0.9px'>销售总计:¥"+price2_all+"</font>";
             }
         }],
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值