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

Hiding 'AddNewRecordButton' and Header after postback

3 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RB
Top achievements
Rank 1
RB asked on 22 Oct 2014, 05:46 PM
In my radgrid, on click of AddNewRecord, I open a user control with a search textbox and button. To hide the AddNewRecordButton and Header I have on RadGrid1_ItemCommand I have the following:
if (e.CommandName == RadGrid.InitInsertCommandName)
{
         this._RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
         this._RadGrid1.MasterTableView.ShowHeader = false;                     
 }
But when the search textbox retrieves results and I select one of the entries, a postback is done to display the selected the value, after which the header and AddNewRecordButton are again visible though, the user control is still open. Is there a way to hide it after the postback?

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 Oct 2014, 11:36 AM
Hi,

You can try to use the following property to achieve this requirement:
RadGrid1.MasterTableView.IsItemInserted = false;

Generally, you can check the approach implemented in this live sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultcs.aspx

Hope this helps.

Regards,
Eyup
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
RB
Top achievements
Rank 1
answered on 29 Oct 2014, 07:06 PM
The sample you provided is not exactly what my problem is. 
Where should RadGrid1.MasterTableView.IsItemInserted = false; be added?

0
Eyup
Telerik team
answered on 03 Nov 2014, 11:49 AM
Hi Ruchi,

You can use the following approach to achieve the requested functionality:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    bool isInserting = RadGrid1.MasterTableView.IsItemInserted;
 
    GridHeaderItem headerItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
    headerItem.Visible = !isInserting;
 
    GridCommandItem commandItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0] as GridCommandItem;
    Button button = commandItem.FindControl("AddNewRecordButton") as Button;
    button.Visible = !isInserting;
    LinkButton linkButton = commandItem.FindControl("InitInsertButton") as LinkButton;
    linkButton.Visible = !isInserting;
}

That should do the trick.

Regards,
Eyup
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
Grid
Asked by
RB
Top achievements
Rank 1
Answers by
Eyup
Telerik team
RB
Top achievements
Rank 1
Share this question
or