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

Insert new row on desired position

10 Answers 479 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thiago
Top achievements
Rank 1
Thiago asked on 19 Feb 2013, 12:29 PM
Hello,
I want implement a GridView with the funcionality of add new entries on specific positions. For sample, the grid will be loaded with five static rows, and the user just can add a new row above it. This way, the new row created by the user can be deleted or a new row can be added above it again. So, basically is this: the pre-loaded rows are statics, can´t be deleted, and the new rows can be deleted or a new row can be created above it.
How could I create a new row always above other row? In the nameOfGrid.BeginInsert() method the new row is created on the bottom of grid. 

I´ve attached two images to demonstrate the desired behavior. The first one shows the static rows pre-loaded, just with the option to add a new row. The second shows a new row created on the bottom of grid, with the option to add and remove a row. 

Thanks in advance,

Thiago

10 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 19 Feb 2013, 02:16 PM
Hi,

 You cannot do that using BeginInsert() method of the grid. You should work directly with the collection bound to the grid. For example you can get the index of the current/selected item and use the collection Insert() method.

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Thiago
Top achievements
Rank 1
answered on 19 Feb 2013, 04:22 PM
For sure Vlad.
Thanks by the light.
This is what I was looking for.

Greetings,

Thiago
0
Harshal
Top achievements
Rank 1
answered on 12 Nov 2013, 09:00 AM
Please share the code to do above trick.
0
Ed
Top achievements
Rank 1
answered on 11 Feb 2014, 05:26 AM
Can you provide a sample code to do what you just suggested?

Thanks.
0
Dimitrina
Telerik team
answered on 13 Feb 2014, 03:13 PM
Hi,

This is a sample code snippet illustrating the suggestion of my colleague:
var index = this.clubsGrid.Items.IndexOf(this.clubsGrid.SelectedItem);
clubs.Insert(index, newClub);

Please note that clubs is the collection bound to RadGridView with name clubsGrid.

Regards,
Didie
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Shreya
Top achievements
Rank 1
answered on 13 Oct 2014, 09:37 AM
Hi Dimitrina..
I also want some similar kind of functionality...
Need to Add one static row always at the bottom of all data in my radgrid irrespective of operation (sorting, grouping etc)
The row will need to look similar as below. Pls let me know in case you have any approach. I cant use footer as there s a seperate text for footers.

0
Shreya
Top achievements
Rank 1
answered on 13 Oct 2014, 09:38 AM
Here is the screenshot for my problm
0
Dimitrina
Telerik team
answered on 13 Oct 2014, 02:10 PM
Hello,

You could redefine the template of RadGridView and embed your own custom footer and define it as you wish. 
Using Implicit Styles gives you the ability to easily extract and edit the default ControlTemplates of the controls. You can also follow this article on two different approaches on how to extract the ControlTemplates.


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Shreya
Top achievements
Rank 1
answered on 14 Oct 2014, 03:11 PM
Thanks for the response.
I cannot customize the footer of my grid, As I have some already data for footer. Can you suggest any other way to add just a static row at the end of all rows in grid as in the screenshot apart from footer.
0
Dimitrina
Telerik team
answered on 16 Oct 2014, 07:47 AM
Hello,

There is not a way to configure our control to just add a static row at the end of all rows, however, once you edit its template, you can modify it in any way you wish.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Thiago
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Thiago
Top achievements
Rank 1
Harshal
Top achievements
Rank 1
Ed
Top achievements
Rank 1
Dimitrina
Telerik team
Shreya
Top achievements
Rank 1
Share this question
or