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

Tool Bar In CommandItemTemplate

4 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
HarryS
Top achievements
Rank 1
HarryS asked on 25 Aug 2010, 09:55 AM
Hi,

I seem to have a simple issue that I can't fix!

I have a RadToolBar within a RadGrid CommandItemTemplate.
When clicking any tool bar button, the functionality works fine but the state (ie: Checked) is lost.

When the button is clicked, the datatable is filtered, then I recall DataBind() then the tool bar button resets to the 'off' state.
Snippet below,

Any ideas for a quick fix?

Thanks,
Harry

  <CommandItemTemplate>
           <div class="filterEvents1">
<telerik:RadToolBar ID="tbButtons" runat="server" EnableEmbeddedBaseStylesheet="false" EnableEmbeddedSkins="false"   OnButtonClick="RadToolBar1_ButtonClick" EnableViewState="true" AutoPostBack="false" >
<Items>
<telerik:RadToolBarButton  CheckOnClick="true" ImageUrl="~/images/ico-all-inactive.png" Group="showAll"
CheckedImageUrl="~/images/ico-all-active.png" height="19px" Checked="false"  CommandName="showAll"  />

4 Answers, 1 is accepted

Sort by
0
HarryS
Top achievements
Rank 1
answered on 26 Aug 2010, 02:40 PM
I've still had no joy fixing this!!

To clarify what is happening;
When a toolbar button is clicked, then the grid is refreshed with an up-to-date DataTable, then I call grdEvents.Databind().

When the grid is bound again, then the toolbar item loses it's 'checked' status.
Anyone know how I can stop this happening please!!!

Thanks,
H

Sample of the codebehind that is being called!

protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
    {
        RadToolBarButton btnBloodGlu = e.Item as RadToolBarButton;
        string ClickedText = btnBloodGlu.CommandName.ToString();
        GridFilterButtons(ClickedText);
        btnBloodGlu.Checked = true;
    }
     
    public void GridFilterButtons(string filterName)
    {
        DataTable tableFiltered = rawJournalFilteredData.JournalViewDataFiltered(filterName);
        grdEvents.DataSource = tableFiltered;
        grdEvents.Rebind();    
    }


0
Maria Ilieva
Telerik team
answered on 30 Aug 2010, 12:45 PM
Hi Harry,

The described behavior is expected in such scenarios. The only option for avoiding it is to use the ToolBar ButtonClick event and keep the checked status in the ViewState. After that you could retrieve this status in the ToolBar PreRender event.
I hope this helps.



Sincerely yours,
Maria Ilieva
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
brian
Top achievements
Rank 1
answered on 02 May 2011, 10:36 PM
Why is this the expected behavior?

Many times, we use the ToolBar in the CommandItemTemplate of a Grid but have to manually remain state.   It would be a nice feature if it was automatic.

Thanks.
0
Maria Ilieva
Telerik team
answered on 05 May 2011, 09:52 AM
Hello,

When the RadGrid is additionally bind on specific action it could not keep its previous state automatically. Therefore you should kept the needed settings in the ViewState.

Greetings,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
HarryS
Top achievements
Rank 1
Answers by
HarryS
Top achievements
Rank 1
Maria Ilieva
Telerik team
brian
Top achievements
Rank 1
Share this question
or