This question is locked. New answers and comments are not allowed.
Hello,
As i understand it I need to return the full dataset back to the webpage after editing/updating an item.
my code is:
but the problem i have is the dataset was filtered in the first place. IE:
as you can see
ID was send to the index view so i can say select all items that are in category "knives"
But the edit function only sends to the controller the product_guid as to edit the product, ut i also need the "Knives" so i can send back the correct data that was queried in the first place.
so I cannot get the value that i filtered with for that page in the first place.
So I thought about getting creative and say will if I changed things around and
added
As i understand it I need to return the full dataset back to the webpage after editing/updating an item.
my code is:
<%= Html.Telerik().Grid(Model) .Name("Productin") .DataKeys(keys => keys.Add(c => c.Product_GUID)) .DataBinding(dataBinding => dataBinding .Ajax() .Update("Update", "Examples") ) .Columns(columns => { columns.Bound(o => o.Product_key).Title("Part #").ReadOnly(); columns.Bound(o => o.Dbman_descrition).ReadOnly(); columns.Bound(o => o.Pattern_Name).ReadOnly(); columns.Bound(o => o.Manufacturer_Name).ReadOnly(); columns.Bound(o => o.pre).ReadOnly(); columns.Bound(o => o.qty).ReadOnly(); columns.Bound(o => o.Retail_Price).ReadOnly(); columns.Bound(o => o.sortorder); columns.Bound(o => o.Pattern_Name).Visible(false); columns.Command(commands => { commands.Edit(); }).Width(200); }) .Pageable().Filterable() %> but the problem i have is the dataset was filtered in the first place. IE:
IQueryable<productlist> PinCat = null; if (!string.IsNullOrEmpty(id)) { PinCat = (from item in storedb.Products_In_Category where item.Product_Categories.Category_Name == id select new productlist { Cat_Guid = item.Cat_GUID, Dbman_descrition = item.Product.Product_Description, Manufacturer_Name = item.Product.Manufacturers_Table.Manufacturer_Name, Pattern_Name = item.Product.Patterns_Table.Pattern_Name, pre = item.Product.PRE, Product_GUID = item.Product.Product_GUID, Product_key = item.Product.Product_Key, Type_name = item.Product.Types_Table.Type_Name, sortorder = item.Product.Item_Sort_Order, qty = item.Product.Quantity, Retail_Price = item.Product.Retail_Price } ).AsQueryable(); ViewData["id"] = id ?? string.Empty; } return View(PinCat);as you can see
where item.Product_Categories.Category_Name == id ID was send to the index view so i can say select all items that are in category "knives"
But the edit function only sends to the controller the product_guid as to edit the product, ut i also need the "Knives" so i can send back the correct data that was queried in the first place.
[AcceptVerbs(HttpVerbs.Post)] [CultureAwareAction] [GridAction] public ActionResult Update(Guid id, FormCollection collection) { var updateproduct = storedb.Products.First(a => a.Product_GUID == id); updateproduct.Item_Sort_Order = Convert.ToInt32(collection["sortorder"]); storedb.SaveChanges(); //add send back the data // but need value of original id of "knives" not this id what was used with editing the item in that category return View(); } so I cannot get the value that i filtered with for that page in the first place.
So I thought about getting creative and say will if I changed things around and
added
columns.Bound(o => o.Category_Name).Visible(false);
I could hide it and maybe it would send that back with the collection.
but no its even visiable to the collection send with the edit command...
I hope i am explaining this well enough, how do i go about solving this with your mvc grid product?