This file is: ext_editgrid_products.js, used to display, edit, and delete data in the products table.
Copy codeThe Code is as follows:
Var productsgrid;
Var productsstore;
Var productslimit = 25; // number of entries per page
Var productsListPostUrl = "/management/procrequest/Proc_products.ashx? Action = getlist ";
Var productsModifyPostUrl = "/management/procrequest/Proc_products.ashx? Action = modify ";
Var productsDeletePostUrl = "/management/procrequest/Proc_products.ashx? Action = del ";
Function initproductsGrid (containerid ){
Ext. menu. RangeMenu. prototype. icons = {
Gt: 'images/greater_then.png ',
Lt: 'images/less_then.png ',
Eq: 'images/equals.png'
};
Ext. grid. filter. StringFilter. prototype. icon = 'images/find.png ';
Ext. QuickTips. init ();
Function formatDate (value ){
Return value? Value. dateFormat ('m d, y '):'';
};
Var fm = Ext. form;
Var sm = new Ext. grid. CheckboxSelectionModel ();
Var cm = new Ext. grid. ColumnModel ([
Sm,
{
Id: 'produtid ',
Header: 'product number ',
DataIndex: 'productid ',
Sortable: true,
Width: 70,
Editor: new fm. NumberField ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'product name ',
DataIndex: 'productname ',
Sortable: true,
Width: 120,
Editor: new fm. TextField ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'amount ',
DataIndex: 'money ',
Sortable: true,
Width: 120,
Editor: new fm. NumberField ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'address ',
DataIndex: 'address ',
Sortable: true,
Width: 120,
Editor: new fm. TextField ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'telephony ',
DataIndex: 'tel ',
Sortable: true,
Width: 120,
Editor: new fm. TextField ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'note ',
DataIndex: 'remark ',
Sortable: false,
Width: 550,
Editor: new fm. myHtmlEditor ({
AllowBlank: false,
AllowNegative: false
})
},
{
Header: 'Port ',
DataIndex: 'Port ',
Sortable: true,
Width: 70,
Editor: new fm. NumberField ({
AllowBlank: false,
AllowNegative: false
})
}
]);
Cm. defaultSortable = true;
/*
Var Plant = Ext. data. Record. create ([
]);
*/
Productsstore = new Ext. data. JsonStore ({
Root: 'LIST ',
TotalProperty: 'totalcount ',
IdProperty: 'produtid ',
RemoteSort: true,
Fields :[
{Name: 'productid'}, {name: 'productname '}, {name: 'money'}, {name: 'address'}, {name: 'tel '}, {name: 'remark'}, {name: 'Port '}
],
Proxy: new Ext. data. ScriptTagProxy ({
Url: productsListPostUrl
})
});
Productsstore. setDefaultSort ('produtid', 'desc ');
Var filters = new Ext. grid. GridFilters ({
Filters :[
{Type: 'string', dataIndex: 'produd d'}, {type: 'string', dataIndex: 'productname '}, {type: 'string', dataIndex: 'money'}, {type: 'string', dataIndex: 'address'}, {type: 'string', dataIndex: 'tel '}, {type: 'string ', dataIndex: 'remark'}, {type: 'string', dataIndex: 'Port '}
]
});
Var pagingBar = new Ext. PagingToolbar ({
PageSize: productslimit,
Store: productsstore,
DisplayInfo: true,
DisplayMsg: 'records {0}-{1}, total {2} records ',
EmptyMsg: "No record"
});
Productsgrid = new Ext. grid. EditorGridPanel ({
Store: productsstore,
Cm: cm,
Sm: sm,
BodyStyle: 'width: 100% ',
AutoWidth: true,
Height: 620,
RenderTo: containerid,
AutoExpandColumn: 'produd d ',
Frame: true,
ClicksToEdit: 2,
Plugins: [filters],
LoadMask: true,
EnableTabScroll: true,
Tbar :[{
Text: 'add ',
Tooltip: 'add new records ',
IconCls: 'add ',
Handler: function (){
OpenTab ("addproducts", "add products", null, initAddproductsForm );
}
},
'-',{
Text: 'editor ',
Tooltip: 'edit selected records ',
IconCls: 'option ',
Handler: function (){
Var selectedRow = productsgrid. getSelectionModel (). getSelections ();
If (selectedRow ){
Var obj = selectedRow [0];
If (! Obj)
Return;
Var id = obj. get ("productId ");
OpenTab ("editproducts", "edit products", null, initAddproductsForm, id, obj );
}
}
},
'-',{
Text: 'delete ',
Tooltip: 'delete selected records ',
IconCls: 'delete ',
Handler: function (){
Var selectedRow = productsgrid. getSelectionModel (). getSelections ();
Ext. MessageBox. confirm ('Confirm', 'Are you sure you want to delete the' + selectedRow. length + "item you selected? ", Function (btn ){
If (btn = 'yes '){
If (selectedRow ){
For (var I = 0; I <selectedRow. length; I ++ ){
Var obj = selectedRow [I];
Var id = obj. get ("productId ");
Productsstore. remove (obj );
$. Ajax ({
Type: "POST ",
Url: productsDeletePostUrl,
DataType: "json ",
Data: "recordid =" + id,
Success: function (msg ){
If (msg [0] & msg [0]. string! = "Success ")
Productsstore. reload ();
}
});
}
}
}
});
}
}],
Bbar: pagingBar
});
Productsstore. load ({params: {start: 0, limit: productslimit }});
Productsgrid. on ("afteredit", afterEdit, productsgrid );
Function afterEdit (obj ){
Var r = obj. record; // get the modified row
Var fildname = obj. field; // get the modified Column
Var id = r. get ("productId ");
Var fildval = obj. value;
$. Ajax ({
Type: "POST ",
Url: productsModifyPostUrl,
DataType: "json ",
Data: {action: 'modify', fildname: fildname, id: id, fildval: fildval },
Complete: function (){
},
Success: function (msg ){
}
});
}
}
This file is ext_add_products.js, used to add or edit the products table.
Copy codeThe Code is as follows:
Var productsAddPostUrl = "/management/procrequest/Proc_products.ashx? Action = add ";
Var productsUpdatePostUrl = "/management/procrequest/Proc_products.ashx? Action = update ";
Function initAddproductsForm (containerid, idstr, rowObj ){
If (! Idstr)
Idstr = containerid;
Var productsForm = new Ext. FormPanel ({
LabelWidth: 100, // label settings here cascade unless overridden
Url: productsAddPostUrl,
Frame: true,
BodyStyle: 'padding: 5px 5px 0 ',
AutoWidth: true,
Ults: {width: '000000 '},
DefaultType: 'textfield ',
RenderTo: containerid,
Items :[
{
Xtype: 'ddy ',
Name: 'produtid ',
Id: 'produtid' + idstr,
Value: null = rowObj? Null: rowObj. get ("productId "),
ReadOnly: true
}
,{
Xtype: 'textfield ',
FieldLabel: 'item name ',
Height: 20,
Name: 'productname ',
AllowBlank: false,
Value: null = rowObj? Null: rowObj. get ("productName "),
Id: 'productname '+ idstr
}
,{
Xtype: 'numberfield ',
FieldLabel: 'price ',
Height: 20,
Name: 'money ',
AllowBlank: false,
Value: null = rowObj? Null: rowObj. get ("money "),
Id: 'money' + idstr
}
,{
Xtype: 'textfield ',
FieldLabel: 'address ',
Height: 20,
Name: 'address ',
Value: null = rowObj? Null: rowObj. get ("address "),
Id: 'address' + idstr
}
,{
Xtype: 'textfield ',
FieldLabel: 'telephe ',
Height: 20,
Name: 'tel ',
Value: null = rowObj? Null: rowObj. get ("tel "),
Id: 'tel' + idstr
}
,{
Xtype: 'myhtmleditor ',
FieldLabel: 'note ',
Height: 400, width: 600,
Name: 'remark ',
Value: null = rowObj? Null: rowObj. get ("remark "),
Id: 'remark' + idstr
}
,{
Xtype: 'numberfield ',
FieldLabel: 'Port ',
Height: 20,
Name: 'Port ',
Value: null = rowObj? Null: rowObj. get ("port "),
Id: 'Port' + idstr
}
],
Buttons :[{
Text: 'save ',
Handler: function (){
If (! ProductsForm. form. isValid ())
Return;
ProductsForm. form. submit ({
Meghod: 'post ',
Url :! IsNaN (idstr) & parseInt (idstr)> 0? ProductsUpdatePostUrl: productsAddPostUrl,
WaitMsg: 'saving. Please wait ...',
Success: function (){
Ext. MessageBox. show ({
Title: 'save result ',
Msg: 'saved successfully ',
Buttons: Ext. MessageBox. OK,
Icon: Ext. MessageBox. INFO
});
},
Failure: function (){
Ext. MessageBox. show ({
Title: 'save result ',
Msg: 'failed to save ',
Buttons: Ext. MessageBox. OK,
Icon: Ext. MessageBox. ERROR
});
}
});
}
}]
});
}