I need editable grid in mvc like the
jsgrid demo but, I am unable to implement its js file dynamically
(function() {
var db = {
loadData: function(filter) {
return $.grep(this.clients, function(client) {
return (!filter.Name || client.Name.indexOf(filter.Name) > -1)
&& (!filter.Age || client.Age === filter.Age)
&& (!filter.Address || client.Address.indexOf(filter.Address) > -1)
&& (!filter.Country || client.Country === filter.Country)
&& (filter.Married === undefined || client.Married === filter.Married);
});
},
insertItem: function(insertingClient) {
this.clients.push(insertingClient);
},
updateItem: function(updatingClient) { },
deleteItem: function(deletingClient) {
var clientIndex = $.inArray(deletingClient, this.clients);
this.clients.splice(clientIndex, 1);
}
};
window.db = db;
db.countries = [
{ Name: "", Id: 0 },
{ Name: "United States", Id: 1 },
{ Name: "Canada", Id: 2 },
{ Name: "United Kingdom", Id: 3 },
{ Name: "France", Id: 4 },
{ Name: "Brazil", Id: 5 },
{ Name: "China", Id: 6 },
{ Name: "Russia", Id: 7 }
];
db.clients = [
{
"ID": "x",
"Account": "A758A693-0302-03D1-AE53-EEFE22855556",
"Name": "Carson Kelley",
"RegisterDate": "2002-04-20T22:55:52-07:00"
},
{
"Account": "D89FF524-1233-0CE7-C9E1-56EFF017A321",
"Name": "Prescott Griffin",
"RegisterDate": "2011-02-22T05:59:55-08:00"
},
{
"Account": "06FAAD9A-5114-08F6-D60C-961B2528B4F0",
"Name": "Amir Saunders",
"RegisterDate": "2014-08-13T09:17:49-07:00"
},
{
"Account": "EED7653D-7DD9-A722-64A8-36A55ECDBE77",
"Name": "Derek Thornton",
"RegisterDate": "2012-02-27T01:31:07-08:00"
},
{
"Account": "2A2E6D40-FEBD-C643-A751-9AB4CAF1E2F6",
"Name": "Fletcher Romero",
"RegisterDate": "2010-06-25T15:49:54-07:00"
},
{
"Account": "3978F8FA-DFF0-DA0E-0A5D-EB9D281A3286",
"Name": "Thaddeus Stein",
"RegisterDate": "2013-11-10T07:29:41-08:00"
},
{
"Account": "658DBF5A-176E-569A-9273-74FB5F69FA42",
"Name": "Nash Knapp",
"RegisterDate": "2005-06-24T09:11:19-07:00"
},
{
"Account": "76D2EE4B-7A73-1212-F6F2-957EF8C1F907",
"Name": "Quamar Vega",
"RegisterDate": "2011-04-13T20:06:29-07:00"
}
];
}());
I have tried to change js like below but how will I implement filtering and all other method?.If anyone have solution please share.
(function () {
debugger;
var db = {
loadData: function (filter) {
return $.ajax({
type: "GET",
url: "/Merchandise/GetMerchandise",
data: filter,
dataType: "json"
});
},
insertItem: function (insertingClient) {
this.clients.push(insertingClient);
},
updateItem: function (updatingClient) {
var barcode = updatingClient.Barcode;
debugger;
},
deleteItem: function (deletingClient) {
debugger;
var clientIndex = $.inArray(deletingClient, this.deletingClient);
this.deleteItem.splice(clientIndex, 1);
}
};
window.db = db;
db.countries = [
{ Name: "", Id: 0 },
{ Name: "United States", Id: 1 },
{ Name: "Canada", Id: 2 },
{ Name: "United Kingdom", Id: 3 },
{ Name: "France", Id: 4 },
{ Name: "Brazil", Id: 5 },
{ Name: "China", Id: 6 },
{ Name: "Russia", Id: 7 }];
db.Locations = [];
db.damages = [];
db.clients = [];
$.get("/Merchandise/GetMerchant",
function (data) {
debugger;
db.Locations = data.lst;
db.damages = data.lst1;
db.clients = data.ItemList;
}, "json");
}());