This is a migrated thread and some comments may be shown as answers.

Add multiple rows with inline editing on button click

1 Answer 569 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Subin
Top achievements
Rank 1
Subin asked on 15 Jan 2017, 06:00 AM

Hi,

I have a requirement where for first time, kendo grid should be opened in in-line editing mode with 5 columns containing dropdowns. When i click on button specifying number of rows, for example 5 then 5  new rows should be created with inline editing.

Can you please help me how can i achieve this scenario.

 

Below is how grid looks like. 

 

----------------------------------------------------------------------------------

# |  Product type| Product Name | Product Range | Quantity |   ==> this header

----------------------------------------------------------------------------------

1     dropdown |      dropdown     |    dropdown       |  dropdown - 1st row   

----------------------------------------------------------------------------------

2     dropdown |      dropdown     |    dropdown       |  dropdown - 2 nd row

 

   Button => to specify number of rows.

 

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 17 Jan 2017, 11:47 AM
Hi Subin,

Kendo UI Grid for ASP.NET MVC does not support editors in the ClientTemplate out of the box, but you can bind them in a similar manner:
columns.Bound(p => p.UnitPrice).Width(120).ClientTemplate("<input data-role='numerictextbox' data-bind='value: UnitPrice' data-min='-99' style='width: 80px;'/>"); ;

And within the DataBound event of the grid you will have to bind the model to the template:
function dataBound(e) {
    var grid = this;
    grid.element.find("[role='row']").each(function () {
        var tr = $(this).closest('tr');
        var item = grid.dataItem(tr);
        kendo.bind($(this), item);
    });
}

As for adding multiple items, you can use the add method of the DataSource of the grid:

Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Subin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or