Home Forums WPF controls Xceed DataGrid for WPF Conditional readonly for each datarow

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25978 |

    hi,

    I want to make some of the rows as readonly in my datagrid. After I bind the grid with ItemSource, what is the best way to do it?
    If I use GetContainer methods to retrive the rows and mark them as readonly, it works for only the rows in view point. what about the others?

    Please let me know.
    Thanks,
    Jagadeesh

    Imported from legacy forums. Posted by jagadeesh (had 6302 views)

    Xceed Support
    Member
    Post count: 5658

    You could create an implicit style targeting DataRow and use a DataTrigger to set its ReadOnly property.

    This will hit all rows as soon as they appear in the viewport.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 542 views)

    User (Old forums)
    Member
    Post count: 23064

    hi,

    can you please point me to any samples or code snippet that does the same?

    Thanks,
    Jagadeesh

    Imported from legacy forums. Posted by jagadeesh (had 700 views)

    User (Old forums)
    Member
    Post count: 23064

    Any Help for this problem I’m having the same issue?

    Dan

    Imported from legacy forums. Posted by Dan (had 517 views)

    Xceed Support
    Member
    Post count: 5658

    <Styles TargetType={x:Type xcdg:DataRow}>
    <Styles.Triggers>
    <DataTrigger Binding={Binding to whatever property you want to check}
    Value=”the value you want”>
    <Setter Property=”ReadOnly” Value=”True”/>
    </DataTrigger>
    </Styles.Triggers>
    </Styles>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 443 views)

    User (Old forums)
    Member
    Post count: 23064

    Jenny,

    I have a DataGrid bound to a DataGridCollectionViewSource. I am attempting the style you posted like this:

    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Style.Triggers>
    <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Self}, Path=DataContext,
    Converter={StaticResource canEditConverter}}” Value=”True”>
    <Setter Property=”xcdg:DataRow.ReadOnly” Value=”True”/>
    </DataTrigger>
    </Style.Triggers>
    </Style>

    Hitting a break point in my converter I expected the DataContext passed in to be the domain object in my collection but instead I receive the collection itself.

    This behavior seem different that the behavior described in this thread:

    http://forums.xceed.com/Forums/ShowPost.aspx?PostID=8794

    Any help you could provide would be great.

    thanks
    Dan

    Imported from legacy forums. Posted by Dan (had 712 views)

    User (Old forums)
    Member
    Post count: 23064

    Any thoughts? Still stuck on this.

    Dan

    Imported from legacy forums. Posted by Dan (had 599 views)

    Xceed Support
    Member
    Post count: 5658

    What version are you using? Using 2.0, we get Row.DataContext to be the Collection DataItem as expected.

    Would you be possible for you to send a repro app to support@xceedsoft.com mentionning this forum post and address it Christian so we can investigate it further?

    Thanks!

    Imported from legacy forums. Posted by Chris [Xceed] (had 6153 views)

    User (Old forums)
    Member
    Post count: 23064

    I had to do this today, and I struggled with it over and over.

    I finally found the beginning edit trigger, and simply cancelled the editing process for that row with this code.

                 try
                {
                    var source = e.CollectionView.SourceCollection as ObservableCollection<Subject>;
                    var editedSubject = (Subject)e.Item;
                    //
                    //  If this subject is locked, do not let the row go into edit mode.
                    //
                    if (editedSubject.IsLocked)
                    {
                        e.Cancel = true;
                        e.Handled = true;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

    Imported from legacy forums. Posted by Randolph (had 910 views)

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.