Telerik Forums
UI for Silverlight Forum
14 answers
1.3K+ views
The TextBox control has a useful property called MaxLength which limits how many characters you can enter in it.

There does not seem to be an obvious/simple way to do the same thing with a GridViewDataColumn.

The way I got this to work was:

<Controls:GridViewDataColumn DataMemberBinding="{Binding ProductCode,Mode=TwoWay}" Header="Product Code" Width="150">
  <Controls:GridViewDataColumn.CellEditTemplate>
    <DataTemplate>
      <TextBox Text="{Binding ProductCode,Mode=TwoWay}" MaxLength="50"/>
    </DataTemplate>
   </Controls:GridViewDataColumn.CellEditTemplate>
</Controls:GridViewDataColumn>

Is there a better/simpler/less verbose way of achieving this?
John
Top achievements
Rank 1
Iron
 answered on 12 Aug 2022
1 answer
242 views

Hello,

I have an old Silverlight application with the following in the App.xaml file:

      <Style TargetType="tk:GridViewCell" BasedOn="{StaticResource GridViewCellCoreStyle}" />

After updating to the latest, the application no more works: it crashes as soon it displays a GridView control, without any useful error message. It takes me a long time to find the error because I can no more run the application with a debugger and I have no useful error message.

As the application was running fine before I updated Telerik UI for Silverlight, I suppose that the above line is the culprit. Unfortunately, I don't know the previous version of Telerik UI for Silverlight that was used for the application.

I hope this is enough for you to find the bug.

 

Best regards

Patrick
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 22 Feb 2022
8 answers
332 views
Hi,

I have a grid with a lot of columns (20+) and when you sort on the column the horizontal scroll bar resets to the left most position which often hides the column you just sorted (or filtered) on.  I read this was fixed in the Q3 2010 build which we have installed, but the problem persists.  Note, we also freeze several of the columns.

jerry
Stone
Top achievements
Rank 1
 answered on 24 Mar 2021
2 answers
201 views

Hello.

I need update value of RadGridView GridViewCell then she in Edit Mode.

I use MainGrid.BeginningEdit event:

private void MainGridOnBeginningEdit(object sender, GridViewBeginningEditRoutedEventArgs args)
        {
            if(args == null || args.Cell.Value != null) return;

            if (BeginningCellEditEvent != null)
                BeginningCellEditEvent.Invoke(args);
        }

In BeginningCellEditEvent handler i try set new cell value:

private void ActivityDateFactTable_OnBeginningCellEditEvent(GridViewBeginningEditRoutedEventArgs args)
        {
            if((args?.Cell == null || args.Cell.Value != null)) return;
            if(!(args.Row.DataContext is ViewModel viewModel)) return;

            var bindingPath = args.Cell.DataColumn.DataMemberBinding.Path
                                                                            .Path
                                                                            .Replace("[", "")
                                                                            .Replace("]", "")
                                                                            .Split('_');
            if(bindingPath.Length < 3) return;            
            var calcValue = viewModel.GetCalculatedValue(bindingPath[0]);
            if (calcValue != null)
            {                
                args.Cell.Value = calcValue;                
                args.Cell.UpdateLayout();
            }
        }

or

private void ActivityDateFactTable_OnBeginningCellEditEvent(GridViewBeginningEditRoutedEventArgs args)
        {
            if((args?.Cell == null || args.Cell.Value != null)) return;
            if(!(args.Row.DataContext is ViewModel viewModel)) return;

            var bindingPath = args.Cell.DataColumn.DataMemberBinding.Path
                                                                            .Path
                                                                            .Replace("[", "")
                                                                            .Replace("]", "")
                                                                            .Split('_');
            if(bindingPath.Length < 3) return;            
            var calcValue = viewModel.GetCalculatedValue(bindingPath[0]);
            if (calcValue != null)
            {    
                this.Dispatcher.BeginInvoke
                ((Action) delegate
                    {
                        args.Cell.Value = calcValue;
                        args.Cell.UpdateLayout();                   
                    }
                );
            }
        }

Cell.Value is changed, but in UI not updated (as seen on screenshot).

How i can update value in UI after changing him in code and i need that cell stays in edit mode?

Anton
Top achievements
Rank 1
Veteran
 answered on 24 Feb 2021
11 answers
579 views
1) Bind collection to GridView
2) Group on a column
3) set the collection to a new empty collection, or set grid itemssource = null

You should notice that the columns are still on the grid, but the group is removed.

We are trying to persist grouping options across different sets of data, when hitting an empty dataset, the grouping is lost.

The _Grouped and _Grouping events are not fired, however a manual check shows that the GroupDescriptors are indeed cleared.

(This is using Q3 Beta but it was the same behaviour in previous versions)
Dilyan Traykov
Telerik team
 answered on 12 Oct 2020
19 answers
896 views
Hello,

I need to change the language of the localization of a gridview at runtime without creating an instance of a gridview (as shown in the examples). I know, that I have to adapt the templates for the RadGridView but before I start I wanted to ask whether there are any exisiting templates doing dynamic localization which could be provided or whether it is planned to support dynamic localization in a further Telerik version?

Kind regards,
Li
Fernando
Top achievements
Rank 1
 answered on 20 Sep 2020
4 answers
174 views
When i select a row, I have to click on a cell which is then highlighted. Is there any way we keep keep the entire row selected instead of keeping the row selected along with the clicked cell highlighted. 
Dinko | Tech Support Engineer
Telerik team
 answered on 19 Aug 2020
3 answers
271 views
Hello,
We have a problem with column sorting in case column uses converter to display values.
For example:
There is a grid column:
<telerik:GridViewDataColumn DataMemberBinding="{Binding NameToDisplay,
Converter={StaticResource<BR>SimpleLocalizationConverter}}"Width="Auto"><BR><BR></telerik:GridViewDataColumn

Property NameToDisplay is bound to column and it may contains the following values:

Item1, Item2… Item10, Item11… Item20, Item21…

When converter is applied displayed values are:

Item001, Item002… Item010, Item011… Item020, Item021…

The problem is occurring in case sorting is applied.

Instead of having following list of items: Item001, Item002… Item010,
Item011… Item020, Item021… after sorting is performed we have:

Item001, Item010, Item011… Item002, Item020, Item021…

Apparently, sorting works based on bound data, not converted
ones. 

Please advise if there is an appropriate way to avoid this
behaviour?
I cannot change values which are bound to the column and I
would like to avoid custom sorting if it is possible.

Thank you in advance.

Andrew
Top achievements
Rank 1
 answered on 27 May 2020
7 answers
702 views
Hi,

I want to show a simple databound textblock in the RowDetails of a RadGridView, that should be trimmed (using TextTrimming="WordEllipsis") - but so far without luck.
I also read the thread http://www.telerik.com/community/forums/silverlight/gridview/rowdetailstemplate-horizontal-stretch.aspx

This is my xaml (using Silverlight 5 beta):

<telerik:RadGridView x:Name="ContentItemsGrid"
                     ColumnWidth="Auto"
                     AutoExpandGroups="True"
                     AutoGenerateColumns="False"
                     FrozenColumnCount="2"
                     RowIndicatorVisibility="Collapsed"
                     GridLinesVisibility="Horizontal"
                     SelectionMode="Extended"
                     RowDetailsVisibilityMode="Visible"
                     Loaded="ContentItemsGrid_Loaded">
 
    <telerik:RadGridView.Columns>
        <telerik:GridViewSelectColumn />
        <telerik:GridViewImageColumn DataMemberBinding="{Binding Image}" />
        <telerik:GridViewImageColumn DataMemberBinding="{Binding ContentStateIcon}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Caption}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Created, StringFormat=d}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding CreatedUser}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding LastChanged, StringFormat=d}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding ChangedUser}" />
    </telerik:RadGridView.Columns>
 
    <telerik:RadGridView.RowDetailsStyle>
        <Style TargetType="telerik:DetailsPresenter">
            <Setter Property="HorizontalContentAlignment"
                    Value="Stretch" />
        </Style>
    </telerik:RadGridView.RowDetailsStyle>
 
    <telerik:RadGridView.RowDetailsTemplate>
        <DataTemplate>
            <Grid Background="White">
                <TextBlock Text="{Binding Preview}"
                           Margin="30 0 5 0"
                           TextTrimming="WordEllipsis" />
            </Grid>
        </DataTemplate>
    </telerik:RadGridView.RowDetailsTemplate>
 
</telerik:RadGridView>

I tried a lot of different things in the DataTemplate: StackPanel, Grid, Grid.ColumnDefinition="*" etc.
But the result always looks like in the screenshot.

Any ideas, please?

cheers
Thomas 
Joe
Top achievements
Rank 1
 answered on 13 May 2020
3 answers
347 views
I'm not having much success in what I thought would be a simple process (at least is was in Windows Forms apps).

I have a GridView bound to an observableCollection ... columns are being displayed correctly with bound data.  I simply want to do some additional processing when my GridViewCheckBoxColumn is checked (or unchecked).

Any hints on how to accomplish this?  I've surfed and read the documentation and there is NOTHING about how to respond to a GridViewCheckBoxColumn event -- I'm guessing this must be a pretty common task??  But so far, I haven't been able to find any event that will consistently work with a GridViewCheckBoxColumn check/uncheck.

Thanks, Rob.

Hai
Top achievements
Rank 1
 answered on 13 Apr 2020
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?