Display and allow only a single row

5 posts, 0 answers
  1. Duke
    Duke avatar
    21 posts
    Member since:
    Dec 2016

    Posted 02 Mar 2017 Link to this post

    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.

  2. Duke
    Duke avatar
    21 posts
    Member since:
    Dec 2016

    Posted 02 Mar 2017 Link to this post

    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.

  3. Stefan
    Admin
    Stefan avatar
    3009 posts

    Posted 06 Mar 2017 Link to this post

    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 visualization (charts) and form elements.
  4. Duke
    Duke avatar
    21 posts
    Member since:
    Dec 2016

    Posted 06 Mar 2017 in reply to Stefan Link to this post

    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

  5. Stefan
    Admin
    Stefan avatar
    3009 posts

    Posted 08 Mar 2017 Link to this post

    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 visualization (charts) and form elements.
Back to Top