Use addNewRecord to add a record to the bottom of the grid not the top

7 posts, 1 answers
  1. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 04 Nov 2013 Link to this post

    Greetings,

    I'm currently evaluating RadGrid as my manager considers using it in a new project.
    My manager asked me to examine the batch mode. One of his requirements is that new rows should be added to the bottom of the grid instead of the current behaviour of adding to the top.

    addNewRecord adds to the top by default. Can I configure the grid to change this behaviour?
    And if the answer is no, can I resort to a DOM hack to add the record TR element to the bottom? Will this be safe?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2013 Link to this post

    Hi Ashraf,

    Please try setting the InsertItemPageIndexAction property of MasterTableView of the RadGrid. It contains values such as ShowItemOnFirstPage, ShowItemOnCurrentPage and ShowItemOnLastPage.

    ASPX:
    <MasterTableView InsertItemPageIndexAction="ShowItemOnLastPage">

    Thanks,
    Princy


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 06 Nov 2013 Link to this post

    No, this doesn't do the trick.
    What I understand, is that the masterTableView object controls server side operations. Its properties don't effect client side operations done while using the batch mode. It's the batchEditingManager who controls those.

    I've done the required functionality using a simple DOM manipulation, and it seems to work.
    I handled the client side OnRowCreated event this way:

    function grid_rowCreated(sender, args)
    {
        //New records don't have data keys values set yet
        if(args.getDataKeyValue(sender.get_masterTableView().get_clientDataKeyNames()[0]) == null)
        {
            var item = args.get_item(),
            jParent = $(item.get_parent().get_element()),
            jElem = $(item.get_element()).remove();
     
            jParent.children("tbody").append(jElem);
        }
    }


    By the way, where's the documentation of batchEditingManager? I can't find its API documentation.
  5. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 06 Nov 2013 Link to this post

    batchEditingManager's functions are described here
    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html
  6. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 27 Nov 2013 Link to this post

    Was this behaviour changed?
    After installing the newly released service pack, now I notice that the default behaviour of the grid is adding new rows to the bottom as I wanted initially, but I can't remember that I read this in the change log.
  7. Answer
    Deyan Enchev
    Admin
    Deyan Enchev avatar
    60 posts

    Posted 02 Dec 2013 Link to this post

    Hello Ashraf,

    When using the Batch Editing functionality of our RadGrid control you have the ability to set where new rows appear – top or bottom of the Grid. This is done by using the InsertItemDisplay property within the MasterTableView itself. This property has two values Top and Bottom and the default value is Top.
     
    When adding new row using the RadGrid Batch Editing, each new row should be added to the Top of the Grid as this is the default behavior. Could you take a look at your markup and recheck is the InsertItemDisplay property set to a certain value? If it is not set and you are still getting the new row added to the bottom than there might be some other reason for this to happen. Providing a small runnable project will help us further debug your application and get back to you with more straight to the point answers.


    Regards,
    Deyan Enchev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Ashraf Sabry
    Ashraf Sabry avatar
    88 posts
    Member since:
    Jan 2011

    Posted 02 Dec 2013 Link to this post

    Yes, I had InsertItemDisplay set to "Bottom", but this wasn't recognizable by batch mode in the previous version, so I had to make a hack to achieve the behaviour.
    Now it works natively, and I removed my hack. Thanks for your reply.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017