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

来源:互联网 发布:java打印数字菱形 编辑:程序博客网 时间:2024/05/22 16:47
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>";
             }
         }],
原创粉丝点击