ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
ComboBox (text or select) in Grid
Title:
B
I
{code}
?
Hello, I am attempting to add code to add a ComboBox editor (ability for each item to select from dropdown or enter their own value) for Inline Grid editing. I have the current Grid set up for textboxes below. Here is my grid code: @(Html.Awe().Grid(gridId) .Mod(o => o.PageInfo().InlineEdit(Url.Action("Create", "ComponentMan"), Url.Action("Edit", "ComponentMan"))) .Parent("txtSearchInl", "search") .Url(Url.Action("GetItems", "ComponentMan")) .Attr("data-syncg", "dinner") .Columns( new Column { Bind = "id"} .Mod(o => o.InlineId()), new Column { Bind = "Name" } .Mod(o => o.Inline(Html.Awe().TextBox("Name"))), new Column { Bind = "Order"} .Mod(o => o.Inline(Html.Awe().TextBox("Order"))), new Column { Bind = "RequestID"} .Mod(o => o.Inline(Html.Awe().TextBox("RequestID"))), new Column { Bind = "Build1Detail"} .Mod(o => o.Inline(Html.Awe().TextBox("Build1Detail"))), new Column { Bind = "Build2Detail" } .Mod(o => o.Inline(Html.Awe().TextBox("Build2Detail"))), new Column { Bind = "Build3Detail" } .Mod(o => o.Inline(Html.Awe().TextBox("Build3Detail"))), new Column { Bind = "Build4Detail" } .Mod(o => o.Inline(Html.Awe().TextBox("Build4Detail"))), new Column { ClientFormat = GridUtils.InlineEditFormat(), Width = 70 }, new Column { ClientFormat = Html.InlineDeleteFormatForGrid(gridId), Width = 80})) I need to make the Build1Detail - Build4Details all ComboBoxes. I can see in your example (below) that for a regular dropdown you make a call to utils.getItems to fill a regular dropdown. I can't find this method anywhere in the example code. How can I change those 4 textboxes to comboboxes and then also fill them with data ? Code in the view for encode method: @{ var gridId = "ComponentMan"; LabSys.NEWLabSys.LabSysEntities db = new LabSys.NEWLabSys.LabSysEntities(); } <script> var RequestList = @Html.Raw(DemoUtils.Encode(db.Requests.Select(o => new KeyContent(o.id, o.RequestNum)))); </script>
Save Changes
Cancel
eliawesome
asked at 03 Oct 2018
Answers
B
I
{code}
?
`utils.getItems` is in `utils.js` and `meals` is in the page `GridInlinEditDemo/Index.cshtml` var meals = @Html.Raw(DemoUtils.Encode(Db.Meals.Select(o => new KeyContent(o.Id, o.Name)))); you can also use `.Url(url)` instead of `DataFunc`; with `DataFunc` you have the option to use client-side data; to change the textboxes to combobox use `AjaxRadiolist("Prop1").Combobox()` instead of `TextBox("Prop1")`
Save Changes
Cancel
Omu
answered at 03 Oct 2018
I added this code, and got the following error on the encode method, "Only parameterless constructors and initializers are supported in LINQ to Entities". Does this encode method support LINQ to entities using the view? I updated my code above with how I am attempting to do this.
at 03 Oct 2018
eliawesome
you're getting a server side error from entity framework, because of your query; you need to first execute the sql query by calling `.ToList()` and only after that transform into `KeyContent` using select so: db.Requests.ToList().Select(o => new KeyContent(o.id, o.RequestNum))
at 03 Oct 2018
Omu
This worked! Thank you so much for your help. We will be purchasing the full version shortly.
at 03 Oct 2018
eliawesome
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK