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

StatusBar - Displaying a dynamic custom message

5 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 18 Feb 2009, 04:05 PM
Is there a way to show custom messages in the RadGrid statusbar?  If any CRUD operation fails or any exceptions occur I would like to show a message of my choice to the user.

Thanks

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Feb 2009, 04:41 PM
Hello Reid,

You can access the text in the status bar as shown below:

protected void RadGrid1_PreRender(object sender, EventArgs e) 
    RadGrid1.StatusBarSettings.ReadyText = "Total items: " + RadGrid1.Items.Count; 

or:
 GridStatusBarItem item = (GridStatusBarItem)RadGrid1.MasterTableView.GetItems(GridItemType.StatusBar)[0]; 

Please note that the StatusBar will be marked as obsolete
in the next release of RadControls for ASP.NET AJAX which is expected tomorrow.

I recommend you use a CommandItemTemplate  or GridFooterItem instead.
Command item template

Accessing the footer item on PreRender:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    GridFooterItem item = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0]; 
    item["yourColumn"].Text = "Total items: " + RadGrid1.Items.Count; 

I hope that the provided information is helpful.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Reid
Top achievements
Rank 2
answered on 19 Feb 2009, 12:52 AM
Daniel,

Thanks for responding.

Point taken about grim future for the StatusBar.  I do not understand the Column in the Footer?  Do I need to create another column?
0
Shinu
Top achievements
Rank 1
answered on 19 Feb 2009, 04:57 AM
Hi Reid,

You can access the footer of any column in your Grid's column collection using the column's UniqueName property.

ASPX:
                <Columns> 
                   <telerik:GridBoundColumn DataField="ProductName"   UniqueName="ProductName" HeaderText="ProductName" ></telerik:GridBoundColumn> 
                   .............. 
                 
                </Columns> 

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        GridFooterItem item = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0]; 
        item["ProductName"].Text = "Total items: " + RadGrid1.Items.Count;  
    } 


Note: Set the ShowFooter property to true.

Thanks
Shinu




0
Reid
Top achievements
Rank 2
answered on 19 Feb 2009, 05:05 PM
Hello Shinu,

This grid is using an item template and the status text displays but only in the first column (an AutoGeneratedEdit column) when I use a column name in use.  How can you make the message as wide as the grid, and wrap if need be?

Thanks
0
Shinu
Top achievements
Rank 1
answered on 20 Feb 2009, 04:57 AM
Hi,

Try adding a LiteralControl to the Grid to show the Status message and see whether it works.

CS:
     
  RadGrid1.Controls.Add(
new LiteralControl(string.Format("<div style='color:Blue;text-align:center'>{0}</div>""Status Text"))); 

Shinu
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Reid
Top achievements
Rank 2
Shinu
Top achievements
Rank 1
Share this question
or