This document is: Ext_editgrid_products.js, used to display, edit, delete data from the Products table.
Copy Code code as follows:
var Productsgrid;
var Productsstore;
var productslimit = 25; Show number of bars 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: ' ProductId ',
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: ' Phone ',
Dataindex: ' Tel ',
Sortable:true,
WIDTH:120,
Editor:new FM. TextField ({
Allowblank:false,
Allownegative:false
})
},
{
Header: ' Remarks ',
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: ' ProductId ',
Remotesort:true,
Fields: [
{name: ' productId '},{name: ' ProductName '},{name: ' Money '},{name: ' Address '},{name: ' Tel '},{name: ' Remark '},{name: ' P Ort '}
],
Proxy:new Ext.data.ScriptTagProxy ({
Url:productslistposturl
})
});
Productsstore.setdefaultsort (' productId ', ' desc ');
var filters = new Ext.grid.GridFilters ({
Filters: [
{type: ' string ', Dataindex: ' ProductId '}, {type: ' string ', Dataindex: ' ProductName '}, {type: ' string ', dataindex: ' Mo Ney '}, {type: ' string ', Dataindex: ' Address '}, {type: ' string ', Dataindex: ' Tel '}, {type: ' string ', Dataindex: ' Rema RK '}, {type: ' string ', Dataindex: ' Port '}
]
});
var pagingbar = new Ext.pagingtoolbar ({
Pagesize:productslimit,
Store:productsstore,
Displayinfo:true,
Displaymsg: ' {0}-{1} records, 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: ' ProductId ',
Frame:true,
Clickstoedit:2,
Plugins: [Filters],
Loadmask:true,
Enabletabscroll:true,
Tbar: [{
Text: ' Add ',
ToolTip: ' Add new record ',
Iconcls: ' Add ',
Handler:function () {
Opentab ("Addproducts", "Add products", null, initaddproductsform);
}
},
'-', {
Text: ' Edit ',
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: ' Remove ',
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 products tables.
Copy Code code 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,
Defaults: {width: ' 350 '},
DefaultType: ' TextField ',
Renderto:containerid,
Items: [
{
Xtype: ' Hidden ',
Name: ' ProductId ',
ID: ' productId ' + idstr,
Value:null = = Rowobj? Null:rowObj.get ("ProductId"),
Readonly:true
}
, {
Xtype: ' TextField ',
Fieldlabel: ' Product 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: ' Telephone ',
HEIGHT:20,
Name: ' Tel ',
Value:null = = Rowobj? Null:rowObj.get ("tel"),
ID: ' Tel ' + idstr
}
, {
Xtype: ' Myhtmleditor ',
Fieldlabel: ' Remark ',
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: ' Save, please wait ... ',
Success:function () {
Ext.MessageBox.show ({
Title: ' Save Results ',
Msg: ' Save Success ',
Buttons:Ext.MessageBox.OK,
Icon:Ext.MessageBox.INFO
});
},
Failure:function () {
Ext.MessageBox.show ({
Title: ' Save Results ',
Msg: ' Save failed ',
Buttons:Ext.MessageBox.OK,
Icon:Ext.MessageBox.ERROR
});
}
});
}
}]
});
}