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

Asp.net core grid can edit go to another page

3 Answers 403 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 02 Aug 2020, 01:27 PM

I still have a developer edition available to me in my downloads and was wondering. In the grid can one tell the edit button to go to another controller / action ?

 

Regards

3 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 05 Aug 2020, 03:44 PM

Hello David,

If I understand the issue correctly when the 'Edit' button in the Grid is clicked you need to send an additional request. If this is the case, you could subscribe to the Grid beforeEdit or edit event. In the respective event handler, you could send an ajax request to the needed endpoint.  Below is an example:

 .Events(e => e.Edit("onEdit"))

 

 

function onEdit() { $.ajax({ url: "/Home/AdditionalAction", success: function (result) { console.log("Edit") console.log(result)

............. } }); }

Here is a Dojo example where a request is made on the edit event handler of the Grid. 

I hope you will find the provided information helpful

Regards,
Neli
Progress Telerik

0
David
Top achievements
Rank 1
answered on 05 Aug 2020, 04:07 PM
Hi no that is not what i want to achieve I want the edit command column to go to another controller view
0
Neli
Telerik team
answered on 10 Aug 2020, 11:53 AM

Hi David,

As far as I understand the requirements, you need to redirect to another page when the 'Edit' button is clicked, instead of displaying the Grid in one of the built-in edit modes.

If this is the scenario, I would suggest you subscribe to the dataBound event. In the event handler, you could prevent the default behavior and redirect to another view. Below you will find such example:

function onDataBound(e) {
    overrideEditCommand(this);
}
 
function overrideEditCommand(grid) {
    $('.k-grid-edit').on('click', function (e) {
        e.preventDefault();
        e.stopPropagation();
        var dataItem = grid.dataItem($(e.target).closest('tr'));
        window.location.href = "/Home/Edit?id=" + dataItem.OrderID;
    })
}

I hope you will find the provided suggestion helpful. Let us know in case you have additional questions. 

Regards,
Neli
Progress Telerik

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