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

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

6 Answers 426 Views
Grid
This is a migrated thread and some comments may be shown as answers.
أشرف
Top achievements
Rank 1
أشرف asked on 04 Nov 2013, 01:28 PM
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?

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2013, 09:15 AM
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


0
أشرف
Top achievements
Rank 1
answered on 06 Nov 2013, 08:21 AM
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.
0
أشرف
Top achievements
Rank 1
answered on 06 Nov 2013, 09:03 AM
batchEditingManager's functions are described here
http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html
0
أشرف
Top achievements
Rank 1
answered on 27 Nov 2013, 12:07 PM
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.
0
Accepted
Deyan Enchev
Telerik team
answered on 02 Dec 2013, 09:22 AM
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.
0
أشرف
Top achievements
Rank 1
answered on 02 Dec 2013, 10:33 AM
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.
Tags
Grid
Asked by
أشرف
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
أشرف
Top achievements
Rank 1
Deyan Enchev
Telerik team
Share this question
or