Keep add row/delete buttons enabled

6 posts, 0 answers
  1. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 30 May 2013 Link to this post

    Hi!

    I have a GridView with a button above it declared like this:
    <telerik:RadButton Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=DataGrid}" IsEnabledChanged="ButtonAddRow_IsEnabledChanged" />

    As default, the button is disabled when the GridView is in edit mode. I always want it enabled so the user can click it even when editing another row. In that case the current row should be commited and a new row is added.
    My solution to this was to use the IsEnabledChanged event of the button and the set it back to enabled.
    This seems to work, but is there a better solution?

    I also have a delete row button inside the grid declared like this:
    <telerik:GridViewColumn Width="26" IsReadOnly="True" TabStopMode="Skip" IsResizable="False" IsVisible="{Binding IsReadOnly, ElementName=DataGrid, Converter={StaticResource BooleanInvertConverter}}">
        <telerik:GridViewColumn.CellTemplate>
            <DataTemplate>
                <telerik:RadButton Command="telerikGrid:RadGridViewCommands.Delete" CommandParameter="{Binding}" IsEnabledChanged="ButtonDeleteRow_IsEnabledChanged" />
            </DataTemplate>
        </telerik:GridViewColumn.CellTemplate>
    </telerik:GridViewColumn>

    And I tried to do the same there. The button stays enabled, but nothing happens when I click it if the row is in edit mode.
    How can I get around this?

    Regards,
    Håkan



  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 03 Jun 2013 Link to this post

    Hello Håkan,

    It would be better to handle RadButton's Click event and insert the delete/insert - functionality there. I have prepared a sample project for you, illustrating the proposed solution. Please find it attached.

    I hope this helps.


    Regards,
    Yoan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 03 Jun 2013 Link to this post

    Sure that works.
    Would have been nice to use the default command though...

    Regards,
    Håkan
  5. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 03 Jun 2013 Link to this post

    Hi Håkan,

    I understand what your point is. Unfortunately, the behaviour that you have is by design and you cannot change the RadGridViewCommands internal logic.

    Regards,
    Yoan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. srecov
    srecov avatar
    7 posts
    Member since:
    Jul 2013

    Posted 21 Sep 2013 Link to this post

    Hi,

    how can I achive to get GridViewDataControl.Deleting event using button?

    Regards
    Srečo
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Sep 2013 Link to this post

    Hi Srečo,

    The Deleting event is UI event and it will be invoked only with user interaction. It will not be raised if you execute a Delete command in code.

    Please note that the event will be invoked if you define the command on a Button similar to:

     <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
          <telerik:GridViewColumn.CellTemplate>
              <DataTemplate>
                  <telerik:RadButton Command="telerik:RadGridViewCommands.Delete" CommandParameter="{Binding}"/>
              </DataTemplate>
          </telerik:GridViewColumn.CellTemplate>
      </telerik:GridViewDataColumn>

    I hope this helps.
      Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner