How do I programatically put telerik rad grid in "add new" mode on page load
Asked Answered
P

6

9

Seems like this should be easy but I must just be missing something... I have a Telerik RadGrid on a page that allows inline editing. How do I programatically put the grid into edit mode to insert a new row into the grid. When the page loads I would like show the existing data and also display 1 empty row that a user can easily type into to add a new record to the table. (I don't want them to have to push the add new button)

Polacca answered 24/11, 2009 at 19:49 Comment(0)
P
13

Found the answer while back.... updating this in case others need it

RadGrid1.MasterTableView.IsItemInserted = true;
RadGrid1.Rebind();
Polacca answered 19/2, 2010 at 13:38 Comment(0)
A
4

Lifesaver!!

You can set

radGrid1.MasterTableView.IsItemInserted = false;
radGrid1.Rebind();

that will remove the inserted item (like pressing cancel).

Avulsion answered 9/5, 2012 at 11:31 Comment(0)
P
3

If you need show inset form always you can use next:

protected void NeedDataSource(object sender, GridNeedDataSourceEventArgs e) {
  parametersGrid.DataSource = data;
  parametersGrid.MasterTableView.IsItemInserted = true;
}
Pandiculation answered 22/10, 2012 at 11:10 Comment(0)
T
2

You could try using jQuery to press your add button once the page is ready.

Something along the lines of -

$(document).ready(function() {
    $("#addButton").click();
}
Two answered 18/2, 2010 at 21:52 Comment(0)
T
-1

What I did when I wanted to do the same with the Telerik grid is to set the MasterTableView.IsItemInserted property of the control to true inside the OnNeedDataSource event handler. I suppose that it should work if you set the property inside the OnDataBound grid handler as well.

Dick

Trig answered 25/11, 2009 at 14:29 Comment(0)
C
-1
RefreshGrid(userName, "priority", true, false);
RadGrid radGrid = RadGrid1;
radGrid.MasterTableView.InsertItem(); 
radGrid.Rebind();
Constrictive answered 13/8, 2010 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.