var productsgrid;
var productsstore;
var productslimit = 25; //Number of displayed pieces 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) {
= {
gt: 'images/greater_then.png',
lt: 'images/less_then.png',
eq: 'images/'
};
= 'images/';
();
function formatDate(value) {
return value ? ('M d, Y') : '';
};
var fm = ;
var sm = new ();
var cm = new ([
sm,
{
id:'productId',
header: 'Product Number',
dataIndex: 'productId',
sortable: true,
width:70,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'Product Name',
dataIndex: 'productName',
sortable: true,
width:120,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'amount',
dataIndex: 'money',
sortable: true,
width:120,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'Address',
dataIndex: 'address',
sortable: true,
width:120,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'phone',
dataIndex: 'tel',
sortable: true,
width:120,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'Note',
dataIndex: 'remark',
sortable: false,
width:550,
editor: new ({
allowBlank: false,
allowNegative: false
})
},
{
header: 'port',
dataIndex: 'port',
sortable: true,
width:70,
editor: new ({
allowBlank: false,
allowNegative: false
})
}
]);
= true;
/*
var Plant = ([
]);
*/
productsstore = new ({
root: 'list',
totalProperty: 'totalCount',
idProperty: 'productId',
remoteSort: true,
fields: [
{name: 'productId' },{name: 'productName' },{name: 'money' },{name: 'address' },{name: 'tel' },{name: 'remark' },{name: 'port' }
],
proxy: new ({
url: productsListPostUrl
})
});
('productId', 'desc');
var filters = new ({
filters: [
{ type: 'string', dataIndex: 'productId' }, { 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 ({
pageSize: productslimit,
store: productsstore,
displayInfo: true,
displayMsg: 'Third {0} - {1} records, total {2} records',
emptyMsg: "No record"
});
productsgrid = new ({
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 a new record',
iconCls: 'add',
handler:function(){
openTab("addproducts", "add products", null, initAddproductsForm);
}
},
'-', {
text: 'Edit',
tooltip: 'Edit selected record',
iconCls: 'option',
handler: function() {
var selectedRow = ().getSelections();
if (selectedRow) {
var obj = selectedRow[0];
if (!obj)
return;
var id = ("productId");
openTab("editproducts", "editproducts", null, initAddproductsForm, id, obj);
}
}
},
'-', {
text: 'Delete',
tooltip: 'Delete selected record',
iconCls: 'remove',
handler: function() {
var selectedRow = ().getSelections();
('Confirm', 'Are you sure you want to delete the ' + + "item?", function(btn) {
if (btn == 'yes') {
if (selectedRow) {
for (var i = 0; i < ; i++) {
var obj = selectedRow[i];
var id = ("productId");
(obj);
$.ajax({
type: "POST",
url: productsDeletePostUrl,
dataType: "json",
data: "recordsuccess")
();
}
});
}
}
}
});
}
}],
bbar: pagingBar
});
({ params: { start: 0, limit: productslimit} });
("afteredit", afterEdit, productsgrid);
function afterEdit(obj) {
var r = ; //Get the modified row
var filtername = ; //Get the modified column
var id = ("productId");
var fildval = ;
$.ajax({
type: "POST",
url: productsModifyPostUrl,
dataType: "json",
data: { action: 'modify', fildname: fildname, id: id, fildval: fildval },
complete: function() {
},
success: function(msg) {
}
});
}
}