This question is locked. New answers and comments are not allowed.
Stéphan Parrot
Top achievements
Rank 1
Stéphan Parrot
asked on 14 May 2010, 07:00 PM
Hello folks!
I've written a small script that allows to add a new row at the very last position of the grid's item collection!
Natively, it's not supported yet so, I came up with a small fix as follow:
If someone finds any problems or have better ideas or any suggestions, please, contribute!
Thanks and I hope this will help some of you guys out there!
Stéphan
I've written a small script that allows to add a new row at the very last position of the grid's item collection!
Natively, it's not supported yet so, I came up with a small fix as follow:
| $('.t-grid-add').live('click', function (e) { |
| //Get the new inserted row |
| var newRow = $('.t-grid-new-row'); |
| //Get the last row of the grid's body |
| var lastRow = $(newRow).parent().children().last(); |
| //checks that it's not the new inserted row |
| //(meaning there's no item added yet to the grid |
| if ($(lastRow).attr('className') != "t-grid-new-row") { |
| //Append the new row at the very last position |
| //of the rows in the grid's body |
| $(lastRow).after($(newRow)); |
| } |
| //Selects the first text input box of the new row |
| $(".text-box").first().focus(); |
| }); |
If someone finds any problems or have better ideas or any suggestions, please, contribute!
Thanks and I hope this will help some of you guys out there!
Stéphan
15 Answers, 1 is accepted
0
Gopinath
Top achievements
Rank 1
answered on 19 Jun 2010, 10:09 PM
Hi Stephan,
How can we use this (adding a new row at the bottom of grid) ? Can you post a small demo code?
We are using the regular telerik grid in aspx web form. When user clicks on a button, we need to add a new row..
Thanks,
varadhg
How can we use this (adding a new row at the bottom of grid) ? Can you post a small demo code?
We are using the regular telerik grid in aspx web form. When user clicks on a button, we need to add a new row..
Thanks,
varadhg
0
Stéphan Parrot
Top achievements
Rank 1
answered on 21 Jun 2010, 01:16 PM
Hi varadhg,
Simply add this script in your page's header in a <script></script> tag OR even better, put it in a separate javascript file that you load using Html.Telerik().ScriptRegistrar as follow:
As you can see, it's very simple.
Let me know if you have other questions!
Best of luck!
Stéphan
Simply add this script in your page's header in a <script></script> tag OR even better, put it in a separate javascript file that you load using Html.Telerik().ScriptRegistrar as follow:
| <asp:Content ID="headContent" ContentPlaceHolderID="Head" runat="server"> |
| <% |
| Html.Telerik().ScriptRegistrar() |
| .DefaultGroup(scripts => scripts |
| .Add("~/Scripts/myjavascriptfilecontainingthenewrowfix.js")); |
| %> |
| </asp:Content> |
| <asp:Content ID="main" ContentPlaceHolderID="MainContent" runat="server"> |
| <%= |
| Html.Telerik().Grid(Model) |
| .Name("MyGrid") |
| %> |
| </asp:Content> |
As you can see, it's very simple.
Let me know if you have other questions!
Best of luck!
Stéphan
0
Gopinath
Top achievements
Rank 1
answered on 21 Jun 2010, 02:22 PM
Thanks Stephan,
But I guess your code ref' to MVC Model, correct?
We're not using MVC, it is plain old asp.net web form (post-back) with telerik gird, can we still use this code bit?
In our page we've the telerik grid with no data bind and 10 empty rows, we need to add row(s) based on user action.
Thanks,
varadhg
But I guess your code ref' to MVC Model, correct?
We're not using MVC, it is plain old asp.net web form (post-back) with telerik gird, can we still use this code bit?
In our page we've the telerik grid with no data bind and 10 empty rows, we need to add row(s) based on user action.
Thanks,
varadhg
0
Stéphan Parrot
Top achievements
Rank 1
answered on 22 Jun 2010, 01:12 PM
Hi varadhg,
Yes, we use telerik's MVC grid so, for your use, you cannot use this code and, I really don't know how to achieve the same thing with the WebForm grid that Telerik offers.
You might want to create a new post in the proper forum so that someone else can help?
I wish you the best of luck!
Have a nice day!
Stéphan
Yes, we use telerik's MVC grid so, for your use, you cannot use this code and, I really don't know how to achieve the same thing with the WebForm grid that Telerik offers.
You might want to create a new post in the proper forum so that someone else can help?
I wish you the best of luck!
Have a nice day!
Stéphan
0
Gopinath
Top achievements
Rank 1
answered on 23 Jun 2010, 02:00 AM
Thanks Stephan,
In some other thread, telerik says it is not supported currently! still dont know what's the big deal in it..:(
Current we copy the row html, and hard-code, and do a jQuery to create a new row..!
Anyhow thanks a lot for your time..
Thanks,
varadhg
In some other thread, telerik says it is not supported currently! still dont know what's the big deal in it..:(
Current we copy the row html, and hard-code, and do a jQuery to create a new row..!
Anyhow thanks a lot for your time..
Thanks,
varadhg
0
Andre
Top achievements
Rank 1
answered on 20 Jul 2011, 07:25 PM
>Hi Manisha,
>
>1. Usually the newly inserted row is getting added at the bottom of the grid. Check out the following links for more details.
>
>Command item
>User control edit form
>
>Thanks
>Princy.
plain old asp.net: (release used Q1 2011)
EditMode="InPlace" InsertItemDisplay="Bottom"
>
>1. Usually the newly inserted row is getting added at the bottom of the grid. Check out the following links for more details.
>
>Command item
>User control edit form
>
>Thanks
>Princy.
plain old asp.net: (release used Q1 2011)
EditMode="InPlace" InsertItemDisplay="Bottom"
0
Timir
Top achievements
Rank 1
answered on 03 Aug 2011, 10:08 PM
Hello,
I use MVC grid.
I used the above JQuery but did not work.
I wan to add additionl link/button on the page and on Click of that button Like to call a function that add row at the bottom ( actually add multiple blank rows based on some calculation).
How can I do that?
I use MVC grid.
I used the above JQuery but did not work.
I wan to add additionl link/button on the page and on Click of that button Like to call a function that add row at the bottom ( actually add multiple blank rows based on some calculation).
How can I do that?
0
Bob
Top achievements
Rank 1
answered on 12 Jan 2012, 09:57 PM
Stephan,
NIce I got this working, with one small change...
var newRow = $('.t-grid-new-row:first');
I added first... probably needed cause I am in batch edit mode rather than row edit mode.
However, setting the focus to the first text box doesn't seem to be working. Perhaps cause I am using CellEdit mode. Is it working for you?
I've tried to change it to:
$(".t-grid-edit-cell .text-box:first").focus();
But still no luck. Any ideas anyone?
BOb
NIce I got this working, with one small change...
var newRow = $('.t-grid-new-row:first');
I added first... probably needed cause I am in batch edit mode rather than row edit mode.
However, setting the focus to the first text box doesn't seem to be working. Perhaps cause I am using CellEdit mode. Is it working for you?
I've tried to change it to:
$(".t-grid-edit-cell .text-box:first").focus();
But still no luck. Any ideas anyone?
BOb
0
Hello Bob,
When you move the inserted rows at the bottom of the Grid when using batch editing, the collection send to the server which represents the updated items will be messed up because the logic tracking the changes depend on the row index.
Regards,
Petur Subev
the Telerik team
When you move the inserted rows at the bottom of the Grid when using batch editing, the collection send to the server which represents the updated items will be messed up because the logic tracking the changes depend on the row index.
Regards,
Petur Subev
the Telerik team
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sebastien
Top achievements
Rank 1
answered on 30 Mar 2012, 08:03 PM
so is there any solution ?
We have to use a grid where the order items are inserted and displayed is crucial.
This is why we need to be able to add new row at the bottom of the grid. We are using asp.net mvc grid in batch editing mode.
We are currently evaluating this set of controls and planning to buy a 10 seats license.
We have to use a grid where the order items are inserted and displayed is crucial.
This is why we need to be able to add new row at the bottom of the grid. We are using asp.net mvc grid in batch editing mode.
We are currently evaluating this set of controls and planning to buy a 10 seats license.
0
Hi Stéphan,
Currently there is no work-around, but since this feature was frequently requested we added it as a new functionality to the Extensions for MVC suite that will appear this month.
Kind Regards,
Petur Subev
the Telerik team
Currently there is no work-around, but since this feature was frequently requested we added it as a new functionality to the Extensions for MVC suite that will appear this month.
Kind Regards,
Petur Subev
the Telerik team
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
answered on 10 Apr 2012, 11:26 AM
Stephan,
i tried using your fix but somehow its not working for me, does it only work if you put the ScriptRegistrar inside the head tags?
i tried using your fix but somehow its not working for me, does it only work if you put the ScriptRegistrar inside the head tags?
0
Stéphan Parrot
Top achievements
Rank 1
answered on 10 Apr 2012, 01:11 PM
Hi Andrew,
I guess so!
Anyways, like Petur Subev wrote, they will put out a new version this month that does it natively! :)
I guess so!
Anyways, like Petur Subev wrote, they will put out a new version this month that does it natively! :)
0
Andrew
Top achievements
Rank 1
answered on 11 Apr 2012, 02:16 AM
i also tried doing it by adding the script in your page's header in a <script></script> tag but still didn't work, im using telerik MVC Grid inline editing with page on scroll enable
0
Amit
Top achievements
Rank 1
answered on 25 Jun 2012, 06:05 PM
Thanks, Andre and Stephan your pointers helped me to right example which showed the InsertItemDisplay property of radgrid, which I needed to show the insert item form in the bottom.
Thanks,
Amit
Thanks,
Amit