I am converting an existing app from Telerik MVC extensions to the newer KendoUI product. I am using the grid control. How do I specify the default values for the columns when adding a new row to the grid?
With the old Telerik MVC extensions, I did the following:
.Editable(editing=>editing.Mode(GridEditMode.InCell).DefaultDataItem(Model.defaultItem))
The defaultItem of my model was my default for added rows. So how do I do this with Kendo?
This article will show, how to work on Kendo UI Grid with ASP.NET MVC. Create a new ASP.NET MVC project . Download Kendo UI for ASP.NET MVC here. Install the TelerikUI for ASP.NET MVC Setup 2016, as shown in the figures, given below: The installation is straight forward. Just choose the required products.
New to Kendo UI for jQuery ? Download free 30-day trial The Grid enables you to handle the appearance of its rows by using the id of the data item, adding custom rows, utilizing row templates, and disabling the hover effect. Make sure the ID field is defined in the model configuration of the data source of the Grid.
The Kendo UI Model field default value can be set to a JavaScript function. In this function, you may obtain the Kendo UI DropDownList instance and its value () and return it. Let me know if you need more help.
For more information, refer to the article on row templates. As of the Kendo UI Q1 2016 release, all Kendo UI themes feature styles for row hovering. Hover is a UI state which provides better visualization across long table rows and when the Grid is in editing mode.
Yo yo yo mate,
You need to specify default value for each of the fields via the dataSource model configuration
Here is an example you can use ;)
@(Html.Kendo()
.Grid<TestModel>()
.Name("SomeOtherGridName")
.DataSource(ds => ds.Ajax().Read("test", "test").Model(
x => {
x.Field(c => c.Val1).DefaultValue(5);
x.Field(c => c.Val2).DefaultValue("cool!");
}
))
.Columns(columns =>
{
columns.Bound(c => c.Val1);
columns.Bound(c => c.Val2);
})
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With