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

Creating a custom edit form

3 Answers 394 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 17 Jul 2013, 01:27 PM
The edit functionality of the grid is not working out for me... 
I have come up with an ajax action link but would like to style it the same as the edit button without it firing the edit. 

so far I have this but it produces one icon in the button and one outside of the button and there is no text, How can I recreate the edit button without it firing the default edit command of the grid?

<a class='k-button k-button-icontext' data-ajax='true' data-ajax-mode='replace' data-ajax-method='Get' data-ajax-update='\\#editorform'  href='/FallsAssessment/Edit?EventID=#=EventID #' data-ajax-success='showModal'><span class='k-icon k-i-pencil'/>Edit</a>
Thanks 

David 

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 17 Jul 2013, 02:07 PM

Hello David,

I would suggest you to use the custom command option of the grid. Using this option you can execute your own function, while you will not need to design the button. Please check this demo:

http://demos.kendoui.com/web/grid/custom-command.html


In your case when you create the custom command you need to set these options in order to display it as a normal edit button, but with custom function executing on click:

{ command: {
        text: "CustomText",
        click: showDetails,
        imageClass : "k-icon",
        iconClass: "k-edit"
}}


For your convenience here is a jsBin example which demonstrates a possible implementation.

Regards,
Kiril
Telerik

Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now! 

0
David
Top achievements
Rank 1
answered on 17 Jul 2013, 02:28 PM
cheers, can a custom command do an ajax call to the controller?  I need to return different forms in partial views and display them.  This is why I chose to do it like below. It's a real pain I have to build the link up as a string too, but the ajax options break your javascript if I use them. I can't see any way to do this with a custom command. 

Also I don't see how to add the options you provided in the MVC html helper, only in the javascript examples. I am using the MVC Html helpers.  

I tried the popupedit but cant figure out how to get the model for the renderpartial in the template. 

columns.Bound(m => m).Template(@<text></text>).ClientTemplate("<a class='k-button k-button-icontext' data-ajax='true' data-ajax-mode='replace' data-ajax-method='Get' data-ajax-update='\\#editorform'  href='/FallsAssessment/Edit?ID=#=ID #' data-ajax-success='showModal'><span class='k-i-pencil'/>Edit</a>");






0
David
Top achievements
Rank 1
answered on 17 Jul 2013, 02:52 PM
I got the markup i needed from the example thanks 

<a class="k-button k-button-icontext k-grid-CustomText" href="#"><span class="k-edit k-icon"></span>CustomText</a>


Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
David
Top achievements
Rank 1
Share this question
or