Home Forums WPF controls Xceed DataGrid for WPF Disable editing functionallity on a row

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

    Hi

    I’ve made a datagrid that allows editing of the grid’s content. But I’d like to lock (disable edit triggers) some of the rows. Is that possible? If so, how?

    Thanks
    Martin

    Imported from legacy forums. Posted by krogh (had 6692 views)

    User (Old forums)
    Member
    Post count: 23064

    One way is to derive a custom row, cell, grid, etc and implement this your self

    OR

    you could Create Custom CellEditors and then disable editing based on the value in a row.

    I dont see this ability available out of the box

    Imported from legacy forums. Posted by MiddleTommy (had 452 views)

    Xceed Support
    Member
    Post count: 5658

    Alternately, you could created a style for DataRow and specify a Trigger or DataTrigger in the style that changes the ReadOnly property of DataRow (effectively disabling edition on the row).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 368 views)

    User (Old forums)
    Member
    Post count: 23064

    I guess that would be the WPF way of doing it
    I have not dove into WPF styles yet.
    So I know nothing about them.

    Imported from legacy forums. Posted by MiddleTommy (had 381 views)

    Xceed Support
    Member
    Post count: 5658

    Well, from my own experience… once you surrender to WPF… you start to see things in a different perspective…

    Lifetime of objects, value of properties, events, triggers, styles, animation… All of those are actually pretty cool.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 290 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks a lot for the suggestions. It worked. I’ve now got a datagrid that can lock rows 🙂

    /Martin

    Imported from legacy forums. Posted by krogh (had 582 views)

    User (Old forums)
    Member
    Post count: 23064

    “Thanks a lot for the suggestions. It worked. I’ve now got a datagrid that can lock rows”

    which suggestion did u take? and can you please post a sample?

    Imported from legacy forums. Posted by Jack (had 338 views)

    User (Old forums)
    Member
    Post count: 23064

    I’d like to know as well.

    Also, similar question, how to disable editing for a column?

    Imported from legacy forums. Posted by fei20100 (had 409 views)

    Xceed Support
    Member
    Post count: 5658

    Column.ReadOnly property is what you are looking for.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 373 views)

    User (Old forums)
    Member
    Post count: 23064

    I think we would all like to know

    How to set a style on a DataRow?
    How to have a style affect the row based on the items the row is displaying’s values?

    Imported from legacy forums. Posted by MiddleTommy (had 365 views)

    User (Old forums)
    Member
    Post count: 23064

    //in your window
    <Window.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source=”Styles.xaml”/>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Window.Resources>

    //in a seperate XAML file Styles.xaml for reuse

    <ResourceDictionary
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://xceedblahblahIforget&#8221;
    <!– Resource dictionary entries should be defined here. –>
    <Style TargetType=”{x:Type xcdg:DataRow}”>
    <Style.Triggers>
    <DataTrigger Binding=”{Binding PropertyOnRowSource}” Value=”PropertyValue”>
    <Setter Property=”Foreground” Value=”Red”/>
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </ResourceDictionary>

    //And thats it
    Pretty simple
    I was trying to get a reference to the DataRow Source and couldn’t find it
    WPF/Xceed does that for you
    the only other thing you might have to do is provide a converter in the DataTrigger binding for complex data types

    Imported from legacy forums. Posted by MiddleTommy (had 7055 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi All,

    I also have to impliment same kind of functionality in my application.

    I am using the above XAML code process to disable editing for some rows.

    But, i am not able to recognize, from which property (in following line) i can compare the Text value of the cell of row.

    <DataTrigger Binding=”{Binding PropertyOnRowSource}” Value=”PropertyValue”>

    Actually, i have to disable some rows to be editable on the basis of the cell content.

     i need the following type of comparision.

    <Style.Triggers>
        <DataTrigger Binding=”{Binding Text}” Value=”ABCD”>

            <Setter Property=”ReadOnly” Value=”True”/>
        </DataTrigger>

        <DataTrigger Binding=”{Binding Text}” Value=”XYZ”>

            <Setter Property=”ReadOnly” Value=”True”/>
        </DataTrigger>

    </Style.Triggers>

    Can any one guide me, how to do that. 

    Imported from legacy forums. Posted by Raghuraj (had 1511 views)

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