i need your help please. I have created a JQXGrid with MVC from two different tables "Prodotti" and "Scheda". I load data from controller with entity framework in this way:
public JsonResult GetProducts()
{
try
{
var dbResult = db.PartnerProducts.ToList();
var products = from e in dbResult
select new
{
e.Id,
e.PartnerId,
e.Title,
e.Price,
e.Quantity,
e.Status,
e.DateCreated,
e.Photo,
e.ShortDescription,
e.LongDescription,
e.cat,
e.lotto,
e.nomeproduttore,
e.origine,
e.idcategoria,
e.apezzo,
e.pesomedio,
e.prezzoscontato,
e.IdSchedaProdotto,
e.Priority,
e.PartnerOwner,
e.Deperibile,
e.inbustati,
e.confezionati,
nomeCategoria = e.categoriaprodottopersonalizzato?.nome,
sottotitolo = e.SchedaProdotto?.Sottotitolo,
provenienza = e.SchedaProdotto?.Provenienza,
curiosita = e.SchedaProdotto?.Curiosita,
proprieta = e.SchedaProdotto?.Proprieta,
periodo = e.SchedaProdotto?.Periodo,
conservazione = e.SchedaProdotto?.Conservazione,
foto = e.SchedaProdotto?.Foto,
titolo = e.SchedaProdotto?.Titolo,
visibile = e.SchedaProdotto?.Visibile,
link = e.SchedaProdotto?.Link,
viaAerea = e.SchedaProdotto?.ViaAerea,
nome = e.SchedaProdotto?.Nome
};
}
return Json(products, JsonRequestBehavior.AllowGet);
}
And i load all data in JQuery table with this code:
datafields: [{ name: 'Id' },
{ name: 'PartnerId' },
{ name: 'Title' },
{ name: 'Price' },
{ name: 'Quantity' },
{ name: 'Status' },
{ name: 'DateCreated' },
{ name: 'Photo' },
{ name: 'ShortDescription' },
{ name: 'LongDescription' },
{ name: 'cat' },
{ name: 'lotto' },
{ name: 'nomeproduttore' },
{ name: 'origine' },
{ name: 'idcategoria' },
{ name: 'apezzo' },
{ name: 'pesomedio' },
{ name: 'prezzoscontato' },
{ name: 'IdSchedaProdotto' },
{ name: 'Priority' },
{ name: 'PartnerOwner' },
{ name: 'Deperibile' },
{ name: 'inbustati' },
{ name: 'confezionati' },
{ name: 'nomeCategoria' },
{ name: 'sottotitolo' },
{ name: 'provenienza' },
{ name: 'curiosita' },
{ name: 'proprieta' },
{ name: 'periodo' },
{ name: 'conservazione' },
{ name: 'foto' },
{ name: 'titolo' },
{ name: 'visibile' },
{ name: 'link' },
{ name: 'viaAerea' },
{ name: 'nome' }
And the load of data works well. Now the problem is when i want to add new data...i read data from column with this function:
addrow: function (rowid, rowdata, position, commit) {
// synchronize with the server - send insert command
// call commit with parameter true if the synchronization with the server is successful
// and with parameter false if the synchronization failed.
// you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB.
var data = "add=true&Id=" + rowdata.Id + "&PartnerId=" + rowdata.PartnerId + "&Title=" + rowdata.Title + "&Price=" + rowdata.Price + "&Quantity=" + rowdata.Quantity + "&Status=" + rowdata.Status;
data = data + "&Photo=" + rowdata.Photo + "&cat=" + rowdata.cat + "&lotto=" + rowdata.lotto + "&origine=" + rowdata.origine + "&idcategoria=" + rowdata.idcategoria;
data = data + "&apezzo=" + rowdata.apezzo + "&pesomedio=" + rowdata.pesomedio + "&prezzoscontato=" + rowdata.prezzoscontato;
data = data + "&IdSchedaProdotto=" + rowdata.IdSchedaProdotto + "&Deperibile=" + rowdata.Deperibile + "&confezionati=" + rowdata.confezionati + "&nomeCategoria=" + rowdata.nomeCategoria;
data = data + "&provenienza=" + rowdata.provenienza + "&viaAerea=" + rowdata.viaAerea + "&periodo=" + rowdata.periodo + "&curiosita=" + rowdata.curiosita;
data = data + "&proprieta=" + rowdata.proprieta + "&conservazione=";
$.ajax({
dataType: 'json',
url: 'AddProducts',
data: data,
success: function (data, status, xhr) {
// update command is executed.
}
});
And i want to realobarate this function from server here:
public bool AddProducts(PartnerProduct product)
The AddProducts
function work fine but in the object Product i can retrieve only value from table Product, such as title or price...How can i save in Jquery values for table "scheda" that are empty in this server-side function?
For example i load data with
titolo = e.SchedaProdotto?.Provenienza,
Pass it to server side with
"&provenienza=" + rowdata.provenienza
but the value in server side of 'Scheda.Provenienza' is empty
Please help me...is very important