Asp.net core grid can edit go to another page

4 posts, 0 answers
  1. David
    David avatar
    77 posts
    Member since:
    Nov 2011

    Posted 02 Aug 2020 Link to this post

    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

  2. Neli
    Admin
    Neli avatar
    397 posts

    Posted 05 Aug 2020 Link to this post

    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

  3. David
    David avatar
    77 posts
    Member since:
    Nov 2011

    Posted 05 Aug 2020 in reply to Neli Link to this post

    Hi no that is not what i want to achieve I want the edit command column to go to another controller view
  4. Neli
    Admin
    Neli avatar
    397 posts

    Posted 10 Aug 2020 Link to this post

    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

Back to Top