Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Editing AddNew template row style
posted

I am using AddNewRow functionality of XDG (displayed by +). Also i have added a last column field with delete button to delete selected row( using delete selected row command). Since i have added delete button with each row by altering cellvaluepresentor style and adding button template to it, this delete button also appears in Addnew template row which is not required there. Can we not any way selectively hide button from addnew template row and just display that with each data row. Or change the functionality of addnew row button to add row in grid with button in the data row still function to delete the record.

Parents
  • 6365
    Verified Answer
    Offline posted

    Hello Tarun,

    In order not to display the Button template for the CellValuePresenter when the record is an AddNew record, an approach I can suggest you is to create a DataTrigger for the respective CellValuePresenterStyle and bind for the IsSpecialRecord property of the current record. Since the AddNew record is a special record, when the property is resolved as True, the CellValuePresenter's Visibility can be set to Collapsed.

    <igDP:Field.CellValuePresenterStyle>
        <Style TargetType="{x:Type igDP:CellValuePresenter}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Record.IsSpecialRecord, RelativeSource={RelativeSource Self}}" 
                                         Value="True">
                      <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </igDP:Field.CellValuePresenterStyle>

    I have prepared a sample application, where I have implemented the behavior from above.
     
    If you require any further assistance on this matter, please do not hesitate to ask.

    XamDataGrid_addNewButton.zip
Reply Children
No Data