How do I programatically put telerik rad grid in “add new” mode on page load

心已入冬 提交于 2019-12-20 20:28:08

问题


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)


回答1:


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

RadGrid1.MasterTableView.IsItemInserted = true;
RadGrid1.Rebind();



回答2:


Lifesaver!!

You can set

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

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




回答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;
}



回答4:


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();
}



回答5:


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




回答6:


RefreshGrid(userName, "priority", true, false);
RadGrid radGrid = RadGrid1;
radGrid.MasterTableView.InsertItem(); 
radGrid.Rebind();


来源:https://stackoverflow.com/questions/1792491/how-do-i-programatically-put-telerik-rad-grid-in-add-new-mode-on-page-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!