Remove Tabstop on grid column when template control is disabled

7 posts, 0 answers
  1. Srikanth
    Srikanth avatar
    7 posts
    Member since:
    Aug 2012

    Posted 14 Jan 2013 Link to this post

    
     <gridColumns:BetaTextBoxColumn Header="Price" Width="80" IsVisible="{Binding Source={StaticResource ParentViewModel}, Path=DataSource.PositionsColumnsVisible}" >
        <telerik:GridViewColumn.CellTemplate>
              <DataTemplate >
                 <TextBox 
                    Text="{Binding [_20047].Value,UpdateSourceTrigger=PropertyChanged,  Mode=TwoWay}" 
                    commonUI:ExtendedProperties.RegEx="{Binding Path=[_20047].RegEx}" 
                    IsEnabled="{Binding Path=[_20047].IsEnabled}"                                        
                    Height="20" MinHeight="20">                      
                  </TextBox>
               </DataTemplate>
         </telerik:GridViewColumn.CellTemplate>
      </gridColumns:BetaTextBoxColumn>

    In the above XAML i need to remove Tabstop for when the Textbox is disabled. Is there a way I can bind the Gridviewtabstop to "IsEnabled" property of templated textbox ?



  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Jan 2013 Link to this post

    Hi,

    You can set the column to be IsEnabled="False" instead. That will remove the TabStop. Would this be a valid option for you?
     

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Srikanth
    Srikanth avatar
    7 posts
    Member since:
    Aug 2012

    Posted 14 Jan 2013 Link to this post

    I don't see "IsEnabled" property on the column?
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 Jan 2013 Link to this post

    Hi,

    Indeed you are right. Please excuse me for misleading you, it turns out that there is not such a property for the column.
    In that case you can bind the value for the TabStopMode to a new property that you can expose in your ViewModel. Based on whether the TextBox should be enabled or disabled, you will return the appropriate value (Skip, Stop) for that new property.
     

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Srikanth
    Srikanth avatar
    7 posts
    Member since:
    Aug 2012

    Posted 14 Jan 2013 Link to this post

    I can do that but I want the tabstop to be specific the gridviewcell not the whole column. Each row in the grid can change based on the business rules. If i change tabstopmode of the column in one row then it applies to all the cells of the column which is not desired in my case.

    I need something that can bind to gridviewcell based the contained templated control inside the cell is enabled or not ?
    I need to bind some property on the gridviewcell to IsEnabled property of the control.

    Any suggestions would be appreciated..


    Thanks.
  6. Srikanth
    Srikanth avatar
    7 posts
    Member since:
    Aug 2012

    Posted 14 Jan 2013 Link to this post

    Any suggestions?
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Jan 2013 Link to this post

    Hello,

    In order to have the TabStop be specific for the GridViewCell, you can define a Style controlling the "IsEnabled" property for the GridViewCell via a Binding to a property of the bound business object. It will be applied per item (cell from the column) and allow/deny the TabStop on that cell.

    For example I have defined a property IsEnabled for the bound item and this is the code I have used to control the enabled state per GridViewCell:

    <Style x:Key="disabledStyle" TargetType="telerik:GridViewCell">
       <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
    </Style>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" CellStyle="{StaticResource disabledStyle}">
        <telerik:GridViewColumn.CellTemplate>
            <DataTemplate >
                <TextBox Text="{Binding Name}"/>
            </DataTemplate>
        </telerik:GridViewColumn.CellTemplate>
    </telerik:GridViewDataColumn>

    I hope this can be applied to your solution.

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top