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

[Solved] Insert, Delete, Edit actions to redirect to custom views

5 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Attila
Top achievements
Rank 1
Attila asked on 05 Sep 2011, 10:27 PM
Hi!

I've a grid, what I'd like to use with Server binding and instead of every action is invoke the action on the Select binding, I'd like to have it invoke the appropriate Select, Update, Insert, Delete action defined in the code.

What I see from the sources the IGridUrlBuilder  implementation is responsible for the consumption of the appropriate DataBinding property, and this implementation is not interchangeble within the grid, since it's a readonly property.

So my goal is that for a Users action which contains the grid, navigate to EditUser, DeleteUser, NewUser action when the user clicks the appropriate buttons within the grid.

I found out that it's only possible by leveraging Column and Toolbar templates. This is where I need some help.

How can I reuse Telerik button builder mechanism in an easy way to generate the Insert, Edit, Delete buttons for me but with my own action links within them?

Thanks,
Attila

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 Sep 2011, 09:02 AM
Hello Attila,

 You can create an ActionLink and set its CSS class to "t-button". This will create a styled button. Here is a sample:

columns.Template(c =>
{
 %>
 <%: Html.ActionLink("Edit", "Edit", "Home", new { id = c.CustomerID }, new { @class="t-button" }) %>
 <%
}).Title("Edit");

Kind regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Attila
Top achievements
Rank 1
answered on 06 Sep 2011, 09:39 AM
Hello Atanas!

Thanks for the answer, I was already aware of this solution, but if you're using Image only or Image and Text as button types that's where it becomes more complicated.

That was the cause I wanted to leverage the Grid control's button building code, since everything is covered there.

As a feature request if you can make the IGridUrlBuilder property of the Grid to get initialized from your DI container instead of hardcoded to
the GridUrlBuilder class, that would also help.

Now I chose to modify the source and GridUrlBuilder class and return the .Update, .Insert properties of DataBinding instead of the .Select properties from the appropriate methods.
This way I don't have to hack around when using the Grid in different forms.

Maybe you should add an "ExternallyControlled" type for EditMode, where editing data on a separate View is possible. For complex forms it's a must. The other thing is showing a model in grid is usually just a subset of the model what you'll edit on the forms.

Thanks,
Attila
0
Accepted
Atanas Korchev
Telerik team
answered on 06 Sep 2011, 01:29 PM
Hello Attila,

 We are planning to implement custom commands in the upcoming release (due November). They will allow to use arbitrary action method and button type. Perhaps this feature would improve the experience.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Ryan
Top achievements
Rank 1
answered on 14 Nov 2011, 03:21 PM
When is this new release available?

Your help content has a section on custom commands, so I was expecting this functionality when I installed 2011.2.914

It would be helpful if the help content was kept accurate.

Thank you.
0
Ryan
Top achievements
Rank 1
answered on 14 Nov 2011, 03:38 PM
Actually I see now that the help is based on release 2011.3.1027 which is currently in beta.

My apologies.
Tags
Grid
Asked by
Attila
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Attila
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Share this question
or