I am having an issue trying to render a check listbox in a grid popup custom editor.
The popup renders with no problem but I get an error when trying to iterate through my collection to render the check boxes.
Custom editor code.
Error Message
The Model in the foreach loop is not initialized and the related collections are null. The above error is because Model.Columns is null.
I can see everything fine in the grid, and if I comment out the above code (to prevent the error), all my other controls render fine showing values from the same Model. I am not understanding why my Model is not initialized when trying to look through the collection.
Do I somehow need to pass the Columns collection from the grid to the popup when it renders? If so - how?
I have sat for 3 hours trying to figure this out as I try to not use the forums if I can help it (due to long times taken to respond, and most of the time responses just ending in "please post a working example" when the code is already self explanatory). I am however stuck in a corner and starting to take flack for late delivery. I literally consume many many hours trying to get KendoUI to work as I need it to, with almost no help from support ): I just don't have time to also have to create examples when the supplied code should be sufficient.
TIA
The popup renders with no problem but I get an error when trying to iterate through my collection to render the check boxes.
Custom editor code.
@model Smartrail.UI.ViewModels.DisplayPanelViewModel
<
div
id
=
"columnsList"
style
=
"height: 110px; overflow: auto;border:solid; width:150px;"
>
@if (Model.Columns != null)
{
foreach (var column in Model.Columns)
{
var checkBoxId = "chk" + column.Id;
var tdId = "td" + column.Id;
<
table
width
=
"100%"
>
<
tr
>
<
td
width
=
"20px"
>
<
input
type
=
"checkbox"
id
=
"@checkBoxId"
value
=
"@column.Id"
/>
</
td
>
<
td
id
=
"@tdId"
width
=
"100px"
>
@column.ColumnCode
</
td
>
</
tr
>
</
table
>
}
}
</
div
>
Error Message
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 4:
Line 5: <
div
id
=
"columnsList"
style
=
"height: 110px; overflow: auto;border:solid; width:150px;"
>
Line 6: @foreach (var names in Model.Columns)
Line 7: {
Line 8: var checkBoxId = "chk" + names.Id;
Source File: d:\Dev\Accutrak\Smartrail02\SourceCode\trunk\SmartrailWeb\Areas\DisplayPanel\Views\Setup\_ColumnsTab.cshtml Line: 6
The Model in the foreach loop is not initialized and the related collections are null. The above error is because Model.Columns is null.
I can see everything fine in the grid, and if I comment out the above code (to prevent the error), all my other controls render fine showing values from the same Model. I am not understanding why my Model is not initialized when trying to look through the collection.
Do I somehow need to pass the Columns collection from the grid to the popup when it renders? If so - how?
I have sat for 3 hours trying to figure this out as I try to not use the forums if I can help it (due to long times taken to respond, and most of the time responses just ending in "please post a working example" when the code is already self explanatory). I am however stuck in a corner and starting to take flack for late delivery. I literally consume many many hours trying to get KendoUI to work as I need it to, with almost no help from support ): I just don't have time to also have to create examples when the supplied code should be sufficient.
TIA