This is a migrated thread and some comments may be shown as answers.

[Solved] client side edit, returning data

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 05 Jan 2011, 07:58 PM
Hello,
   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?
 

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 Jan 2011, 09:40 AM
Hello David,

 You can pass additional arguments to the Update method:

Ajax().Update("Update", "Examples", new { id = 42})

Perhaps this will help you.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or