Hi Experts,
I have a scenario to add the columns dynamically to the kendo grid. I will get the columns from the stored procedure based on the criteria selection from the UI and I need to display those columns in the kendo grid. I have the case like one criteria will give 20 columns and another criteria will give 40 columns etc. So how can i handle view model and how to display them in kendo grid.
Please respond as soon as possible.
Thanks you in anticipation.
4 Answers, 1 is accepted
You can check the Kendo UI Grid demos and also this and this forums.
I would encourage you to refer to the respective forum category for Kendo UI Grid widget on specific questions where my colleagues with deeper knowledge in the specific product can address the case.
Regards,
Dimitrina
Telerik
Hi Dimitrina,
i am binding the columns dynamically like below
for (int col = 0; col < Model.Count; col++)
{
if (Model[col].isIskuAttr > 0)
{
columns.Bound("field" + col).Title(Model[col].attribute).Filterable(ftb => ftb.Multi(true)).Width(200).HtmlAttributes(new { @style = "font-size:8pt;font-family:Arial,sans-serif;text-align:center;" }).HeaderHtmlAttributes(new { @class="iskuAttr",@style="background-color:blue"}).Width(100);
}
else
{
columns.Bound("field" + col).Title(Model[col].attribute).Filterable(ftb => ftb.Multi(true)).Width(200).HtmlAttributes(new { @style = "font-size:8pt;font-family:Arial,sans-serif;text-align:center;" }).HeaderHtmlAttributes(new { @class = "blueConfigAttr", @style = "background-color:darkblue" }).Width(250);
}
}
in the above code, i am applying EditorTemplateName("AvailableValues"), this template will be applied to all columns. when my row went to edit mode. only one row is able to load the editor template. i want all rows to load the same editor template.
here is the code of my editor template
@{
Layout = null;
}
@using Kendo.Mvc.UI
@(Html.Kendo().DropDownList()
.Name("products")
.DataTextField("Text")
.DataValueField("Value")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("getAttributeValues", "BrowseProducts");
});
})
.HtmlAttributes(new { style = "width: 100%" })
)
Can we use same template for all columns in the or we need to use different for every column ? please help me on this.
This forum is for discussions about Telerik Platform by Progress, which is an end-to-end solution for developing and distributing mobile apps. You seem to be working on an ASP.NET MVC project, so please post your question in the respective forum or in Stack Overflow where community discussions about Kendo UI take place.
Regards,
Tsvetina
Telerik by Progress