I have a kendo grid that I try to set different columns as follow
.Columns(columns =>
{
if ((bool)ViewData["resourcePooled"])
{
columns.Bound(s => s.ResourceIdAssignmentName).Width(300);
}
else
{
columns.Bound(s => s.ResourceIdPoolName).Width(300);
}
But it only can set first column, i.e it works only when ViewData["resourcePooled"]=true. When ViewData["resourcePooled"]=false, it doesn't work. Note that above code works well in Telerik MVC Extension. But after in Kendo, it has above problem. I'd like to know what happen. Thanks.
5 Answers, 1 is accepted
Hello york,
The provided sample code seems correct, so we cannot state what is the reason for the behavior on your end. Please provide small isolated runnable example (here or in a support ticket) that demonstrates the issue so we could inspect further.
Regards,Dimiter Madjarov
Telerik

Hi Dimiter,
I attach a sample to show the problem. You can run it and find out where
the problem is. Because the size limit, I remove the package in the
project. The package include, Kendo MVC (2015.1.429.440.Trial), MVC 4
and many others. The simplest way to recreate the solution is to create
new Telerik MVC project (name: MVC_Controls_Kendo) and select .Net 4 and
ASPX (not razor), and add the source files attached.
After launching the project, just click on "Display Pool Info", which will go to PoolInfo.aspx. But PoolInfo.aspx can't be displayed with error: "Specified cast is not valid".
The project has everything it is needed. If you have any question, please let me know. Thanks.
Hello york,
We were unable to run the project on our end due to errors. Nevertheless I would suggest to try the following approach for casting the value to bool instead of the current one.
E.g.
if
(Convert.ToBoolean(ViewData[
"resourcePooled"
]))
{
columns.Bound(p => p.ResourceIdAssignmentName).Width(300);
}
Dimiter Madjarov
Telerik

Thanks, Dimiter.
Can you take a look at another post of mine about opening a kendo window when click in kendo grid cell, http://www.telerik.com/forums/how-to-open-a-window-when-click-in-kendo-grid-cell?
Hello york,
I am glad the information was helpful. I covered the question in the other thread too.
Have a great weekend!
Dimiter Madjarov
Telerik