- Home
- Forum
- ASP.NET MVC
- How to add drop down list contents to a grid.
How to add drop down list contents to a grid.
.Datasource((IEnumerable^BertReport.Models.MethodDeviation^
.EnableRowHover(true)
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("ID").HeaderText("").IsPrimaryKey(true).AllowEditing(false).Visible(false).Add();
col.Field("DeviationReason").HeaderText("Deviation Reason").Width("60%").EditType(EditingType.DropdownEdit).Add();
col.Field("WetRun").HeaderText("W").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Run1").HeaderText("1").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Run2").HeaderText("2").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Run3").HeaderText("3").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Run4").HeaderText("4").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Run5").HeaderText("5").Width("5%").EditType(EditingType.BooleanEdit).Add();
col.Field("Factor").HeaderText("Factor").Width("10%").AllowEditing(false).Add();
})
)
at Object.sendDataRenderingRequest (VM507 ej.web.all.min.js:10)
at Object._processBindings (VM507 ej.web.all.min.js:10)
at Object.startEdit (VM507 ej.web.all.min.js:10)
at Object._toolbarOperation (VM507 ej.web.all.min.js:10)
at Object._toolbar (VM507 ej.web.all.min.js:10)
at Object._trigger (VM507 ej.web.all.min.js:10)
at Object._onItemClick (VM507 ej.web.all.min.js:10)
at HTMLLIElement.
at HTMLLIElement.dispatch (VM506 ej.web.all.min.js:10)
- Please let us know whether you have used any template (column template/edit template)
- Please share us your complete grid rendering code zipped.
- If possible, reproduce the issue in the above sample and share us.
- Share us your version details.
@Scripts.Render("https://cdn.syncfusion.com/js/assets/external/jsrender.min.js") is in the shared layouts file.
It doesn’t look like there are any templates used.
I’ve added the cshtml file which holds these grids, as a zip.
I believe I have trial versions on EJ1 and EJ2 on my machine.
Right now I think I should concentrate on the general edit problem (issue 2 above).
I first got the browser error when I only had EJ2 trial, after talking to support I Installed (syncfusionessentialjavascript-js1_trial) but the error is still appearing. Was this the correct thing I’ve loaded, and do I need to do anything else in order to make the app recognize the EJ1 commands?
Should I remove these trial versions and reinstall a version of EJ1? If so how do I do this what should I be loading?
Attachment: testcshtml_628d2e92.zip
It doesn’t look like the ej.web.all.min.js is not being recognised by the solution in general. As I made a new (standard simple) Controller and View and hooked up the same grid with the same model. This was able to be edited as you would expect when using the view bag, and I was able to wire up save routines to update the database with no issue.
However my initial grids still have the same error. I tried passing the date via view bag rather than the partial view type originally setup.
E.g.
model.DryMethodDeviations = conTxt.MethodDeviations.Where(x => x.JobID == jobID && x.StackID == stackID && x.TestTypeID == testTypeID && x.WetChem == false).ToList();
model.WetMethodDeviations = conTxt.MethodDeviations.Where(x => x.JobID == jobID && x.StackID == stackID && x.TestTypeID == testTypeID && x.WetChem == true).ToList();
ViewBag.datasource = model; //testing
// or
return PartialView(TPMcalclulations(model));
// shows the data, but gives a browser error n.render[(this._id + “JSONEditingTemplate”)] is not a function
But this made no difference, and I’m still getting the same error: see attached screen shot.
So it appears that the issue is with the way the model data is being pulled into the grid.
Could this be because of the partial view?
Or is there something wrong with the permissions of the passed model?
I’ve tried initiating this in the cshtml grid various ways, but it doesn't make any difference.
E.g.
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource.DryMethodDeviations).UpdateURL("NormalUpdate").InsertURL("NormalInsert").RemoveURL("NormalDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) // Using the ViewBag Should jump to the relevant code – works in my test code but doesn’t allow editing in the main
.Datasource((IEnumerable<BertReport.Models.MethodDeviation>)Model.WetMethodDeviations)
// Simple test using the model – also shows text in grid but dosn’t allow editing. (same browser error for both)
Attachment: BrowserError_9507d71b.zip
- Please let us know
- Please share your partial view page, main view page and controller with data model (if possible)
- Share us your version details.
- Please use actionFailure event of grid so that you could find any errors if you get other than console errors.
|
@(Html.EJ().Grid<object>("Grid1").Datasource((IEnumerable<object>)ViewBag.data).AllowPaging()
.ClientSideEvents(eve => eve.ActionComplete("actionComplete"))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
col.Field("CustomerID").HeaderText("Customer ID").EditType(EditingType.DropdownEdit).Add();
}))
<script>
function actionComplete(args) {
//while editing the grid
if (args.requestType == "beginedit" || args.requestType == "add") {
var dpDataSource = [{ value: 'One', text: 'One' }, { value: 'two', text: 'two' }, { value: 'three', text: 'three' }, { value: 'four', text: 'four' }, {
value: 'five', text: 'five'}, ];
$("#Grid1CustomerID").ejDropDownList({ dataSource: dpDataSource, selectedIndex: 1}); //Set the new Dropdown datasource
}
}
</script>
|
- 8 Replies
- 2 Participants
-
GG Garry Grierson
- Feb 6, 2020 10:05 AM UTC
- Feb 24, 2020 01:51 PM UTC