This is a migrated thread and some comments may be shown as answers.

Keep add row/delete buttons enabled

5 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 30 May 2013, 07:16 AM
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



5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 03 Jun 2013, 10:28 AM
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.

0
Håkan
Top achievements
Rank 1
answered on 03 Jun 2013, 11:26 AM
Sure that works.
Would have been nice to use the default command though...

Regards,
Håkan
0
Yoan
Telerik team
answered on 03 Jun 2013, 02:34 PM
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.

0
srecov
Top achievements
Rank 1
answered on 21 Sep 2013, 08:48 PM
Hi,

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

Regards
Srečo
0
Dimitrina
Telerik team
answered on 26 Sep 2013, 07:22 AM
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 >>
Tags
GridView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Håkan
Top achievements
Rank 1
srecov
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or