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

Display and allow only a single row

4 Answers 506 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Duke
Top achievements
Rank 1
Duke asked on 02 Mar 2017, 10:31 PM

I'm using v 2017.1.118.440

There's a requirement to make the grid only allow a single row to be inserted.  Upon loading, there should be a single blank row ready for the user to populate, and no "Add record" button. 

I've disabled the Add record button from the toolbar, but I can't find the settings to have a single row already displaying in the grid and ready for populating.  There doesn't seem to be an onLoad event for the grid to do this.

Any thoughts or suggestions?

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Duke
Top achievements
Rank 1
answered on 02 Mar 2017, 11:47 PM

One approach I found is to create a function that calls grid.addRow(), and bind it to a grid event.

The event that makes most sense would be onLoad, but it unless I'm missing something, an onLoad event doesn't exist for a .net MVC grid (!?).

Can someone clarify if I'm missing something very obvious?

Thanks.

0
Stefan
Telerik team
answered on 06 Mar 2017, 09:49 AM
Hello Duke,

In this scenario I can suggest using the dataBound event of the Grid and a flag to ensure that only one row will be added:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-dataBound

I made an example to demonstrate this. Please have in mind that the example is in jQuery, but the logic in MVC is similar:

http://dojo.telerik.com/ELiJe

I hope this will help to achieve the desired result.

Regards,
Stefan
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 (charts) and form elements.
0
Duke
Top achievements
Rank 1
answered on 06 Mar 2017, 03:35 PM

This works perfectly, Stafan.  Thank you.

So am I right that there's no onLoad() event?  If so, it seems that, depending on the need, the databound() event may often be a good substitute.

-Duke

0
Stefan
Telerik team
answered on 08 Mar 2017, 07:55 AM
Hello Duke,

Yes, this is correct the Grid does not have an onLoad event but depending on the scenario the dataBound event can be used.

Also, please check the other Grids' and DataSource events as they may be better in other scenarios:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events

Regards,
Stefan
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 (charts) and form elements.
Tags
Grid
Asked by
Duke
Top achievements
Rank 1
Answers by
Duke
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or