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

Problem with Programmatic CommandItemSettings hiding/showing options

2 Answers 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Daresta
Top achievements
Rank 1
James Daresta asked on 18 May 2010, 03:49 PM
I am having an issue with programmatically hiding and showing command item settings. Below is the code I am using. The problematic item is the ShowToExportToCsvButton. The goal is that if there are no items then I do not want to show the export to csv button. If there are then show it. The problem is that whichever comes first then that is how it stays. For example if there not records then it does not show and no matter if it does get records in a refresh the button will still not show despite the code setting it to true. Also, if I put in the html markup to show it then it always shows up and I cannot hide it. I am using an ajaxified grid. I am doing this in VS Studio 2010 using 3.5 as the target with RadControls Q1 2010 NET35 v. 2010.1.415.35. Its worth noting that this same thing happens if I try to hide and show the footer with similar code. Is there another place in the process of the grid I should be doing this?

        protected void rgForecastSummaryView_Values_DataBound(object sender, EventArgs e)  
        {  
            if (rgForecastSummaryView_Values.Items.Count > 0)  
            {  
                GridFooterItem footerItem = (GridFooterItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.Footer)[0];  
 
                footerItem["MaterialGroup"].Text = "Grand Totals:";  
                footerItem["MaterialGroup"].Font.Bold = true;  
 
                footerItem["PriorYear"].Text = priorYearTotal.ToString();  
                footerItem["PriorPeriod"].Text = priorPeriodTotal.ToString();  
                footerItem["AccRepForecast"].Text = accountForecastTotal.ToString();  
                footerItem["MgmtAllocation"].Text = managmentAllocationTotal.ToString();  
                footerItem["Difference"].Text = differenceTotal.ToString();  
                 
                rgForecastSummaryView_Values.ShowGroupPanel = true;  
                rgForecastSummaryView_Values.MasterTableView.CommandItemSettings.ShowExportToCsvButton = true;  
 
                GridCommandItem commandItem = (GridCommandItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
                LinkButton lnkbtn1 = (LinkButton)commandItem.FindControlRecursive("InitInsertButton");  
                lnkbtn1.Visible = true;  
 
                ramForecastSummaryView_AjaxManager.AjaxSettings.AddAjaxSetting(lnkbtn1, rgForecastSummaryView_Totals, ralpForecastSummaryView_LoadingPanel);  
                ramForecastSummaryView_AjaxManager.AjaxSettings.AddAjaxSetting(lnkbtn1, rgForecastSummaryView_Values, ralpForecastSummaryView_LoadingPanel);  
            }  
            else 
            {  
                rgForecastSummaryView_Values.ShowGroupPanel = false;  
                rgForecastSummaryView_Values.MasterTableView.CommandItemSettings.ShowExportToCsvButton = false;  
                  
                GridCommandItem commandItem = (GridCommandItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
                LinkButton lnkbtn1 = (LinkButton)commandItem.FindControlRecursive("InitInsertButton");  
                lnkbtn1.Visible = false;  
            }  
        } 

2 Answers, 1 is accepted

Sort by
0
Accepted
Iana Tsolova
Telerik team
answered on 19 May 2010, 12:52 PM
Hello James,

In order the specified property to take effect, you need to rebind the grid after setting it.
Another option is to set the property in the NeedDataSource event handler based on what data is returned from the database.

I hope this helps.

Kind regards,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
James Daresta
Top achievements
Rank 1
answered on 19 May 2010, 02:10 PM
Thanks. That cleared it up for me.
Tags
Grid
Asked by
James Daresta
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
James Daresta
Top achievements
Rank 1
Share this question
or