I need to provide the tooltips for Sort and Filter icon in Rad Silverlight grid with localization.
Please let me know how can achieve this.
Thanks
Balsuyambu S.
11 Answers, 1 is accepted
In order to define a ToolTip for the sorting and filtering indicators, you have to edit the template of the GridViewHeaderCell and set the corresponding ToolTip for each of them. I am sending you a sample project with the required Style and the ToolTips defined. In case you want to localize them, you may bind it to the corresponding localized property.
Maya
the Telerik team
Hi Maya,
Thank you for clarification.
As per my requirement, if sorted column is in Ascending order, i need assign tooltip as "Sort by descending" and if its decending order then tooltip as "Sort by Ascending".
Please update me how can i achieve this and also let me know the Localization property name to apply both the tooltips
Thanks
Balsuyambu S.
You may bind the ToolTip to a property in your ViewModel for example and update during the Sorting event. For example:
XAML:
<
Path
x:Name
=
"PART_SortIndicator"
ToolTipService.ToolTip
=
"{Binding MySortingToolTip, Source={StaticResource MyViewModel}, Mode=TwoWay}"
>
C#:
private void clubsGrid_Sorting(object sender, GridViewSortingEventArgs e)
{
if(e.NewSortingState == SortingState.Ascending)
{
model.MySortingToolTip = "Sort by ascending";
}
else if(e.NewSortingState == SortingState.Descending)
{
model.MySortingToolTip = "Sort by descending";
}
else
{
model.MySortingToolTip = "";
}
}
I am sending you an updated version of the sample attached previously demonstrating the suggested approach.
As for localizing the Resources, you may take a look at this and this articles for further reference.
Maya
the Telerik team
Your solution is working fine. But i am facing another issue.
I want to have a default sort column on page load using sortDescriptor. In this case Tooltip is not displayed for sort state which given in the code behind. but if i click on the column, Tooltip is displayed. Please find the code below
GridViewColumn objColumn = (GridViewColumn)clubsGrid.Columns[1];
SortDescriptor objSort = new SortDescriptor();
objColumn.SortingState =
SortingState.Descending;
objSort.Member =
"Stadium";
clubsGrid.SortDescriptors.Add(objSort);
Please let me know how can i solve this issue.
This would be the expected behavior since Sorting event is not called when define a SortDescriptor or ColumnSortDescriptor initially. What you may do is to set the content of this ToolTip during the definition of the sort descriptor:
SortDescriptor objSort = new SortDescriptor();
objSort.SortDirection = System.ComponentModel.ListSortDirection.Descending;objSort.Member = "StadiumCapacity";
model.MySortingToolTip = "Sort by descending";
this.clubsGrid.SortDescriptors.Add(objSort);
Maya
the Telerik team
Thanks for your response.
I tried to set the content of this ToolTip during the definition of the sort descriptor but tooltip still is not displayed.
is there any alternate way to fix this issue
Thanks
Balsuyambu
I have tested the behavior and everything works correctly on my side. I am sending you the sample project I used for the test. Please take a look at it and let me know in case of any misunderstandings.
Maya
the Telerik team
Thanks for your immediate response.
Yes, it is working the test project which you have sent.
In your test project, Control Template of GridViewHeaderCell has been mentioned through UserControl.Resources. But we have implemented the MergedDictionaries. (<ResourceDictionary.MergedDictionaries>).
It is giving null value in constructor of GridView
model =
this.Resources["MyViewModel"] as MyViewModel;
model is null value
We need to do any other implementation to get the tooltip which has been implemented via MergedDictionaries.
Thanks
Balsuyambu
Thanks for your immediate response.
Yes, it is working the test project which you have sent.
In your test project, Control Template of GridViewHeaderCell has been mentioned through UserControl.Resources. But we have implemented the MergedDictionaries. (<ResourceDictionary.MergedDictionaries>).
It is giving null value in constructor of GridView
model =
this.Resources["MyViewModel"] as MyViewModel;
model is null value
We need to do any other implementation to get the tooltip which has been implemented via MergedDictionaries.
Thanks
Balsuyambu
Generally, the correct implementation depends entirely on the settings and structure of your application. However, the idea should be similar - you have to get access to the place where this particular property - MySortingToolTip in this case - is defined and set it to the value you want. It is not necessary your structure to be as the one of the sample project - the important thing is to update the required property.
Maya
the Telerik team
Thanks for your clarification and found alternate way to solve this issue.
Thanks
Balsuyambu