Note that there are some explanatory texts on larger screens.

plurals
  1. POConfigure list of items to send to server
    text
    copied!<p>I want the user to be able to construct a list of items client-side in a form and then send the entire list to the server when the form is submitted.</p> <p>Each item has several properties that can be set. For example, here's an Order model:</p> <pre><code>class Order { int Id; string Description; Guid UserId; string Product; } </code></pre> <p>The user should be able to add and configure as many orders as they want before submitting the form.</p> <p>I thought I could do this with the Telerik grid using InCell editing. Unfortunately, the list of available options for each field will change based on the value chosen for other fields. I couldn't make this work with InCell editing because I couldn't access the other ui elements from my javascript event handlers.</p> <p>I also tried to do this with normal InLine editing, but the only item returned is the new Order to be added. I couldn't access the GridModel to add the new Order. I don't want to persist the Order list until the user is done editing.</p> <p>Any help would be greatly appreciated.</p> <p>EDIT: If I go with the solution of making my own list, I have this problem with cascading comboboxes. Each combobox has a name like "UserId_0" based on what index it is in the list.</p> <p>But now how do I get the downstream list?<br> Here's my two comboboxes:</p> <pre><code> &lt;td&gt; @(Html.Telerik().ComboBox() .Name("UserId_" + i.ToString()) .BindTo(new SelectList(Model.UserIds, "Id", "Name")) .Placeholder("Select UserId...") .AutoFill(true) .CascadeTo("Product_" + i.ToString()) .SelectedIndex(0)) &lt;/td&gt; &lt;td&gt; @(Html.Telerik().ComboBox() .Name("Product_" + i.ToString()) .AutoFill(true) .DataBinding(binding =&gt; binding.Ajax().Select("GetProducts", "Order")) .Placeholder("Select Product...") .SelectedIndex(0)) &lt;/td&gt; </code></pre> <p>And my Controller method looks like this. It's hacky as hell, but how do I access the value otherwise?</p> <pre><code> public JsonResult GetProducts(Guid? UserId) { // Hack! ValueProviderResult userResult = ValueProvider.GetValue("UserId"); for (int i=0; i &lt; 10; i++) { userResult = ValueProvider.GetValue("UserId_" + i); if (userResult != null) { break; } } if (userResult != null) { // Get list of products based on value return Json(new SelectList(productList, "Id", "Name")); } else { return Json(null); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload