Can I have a 2nd "GridEditMode" on same grid for subset of data?

3 posts, 0 answers
  1. Patrick
    Patrick avatar
    7 posts
    Member since:
    Aug 2015

    Posted 18 Apr Link to this post

    So, I have tried this a bunch of different ways to no result.  My need is I have a Grid filled with some Employees.  You can do the normal things with that Employe object.  Also, I want to have a Custom Command for "Edit Roles" which would popup a different EditablePopupGrid that also uses a ClientTemplate for just the Employee.Roles collection.

    Can I accomplish this?  My grid is using Ajax currently. 

     

  2. Patrick
    Patrick avatar
    7 posts
    Member since:
    Aug 2015

    Posted 20 Apr in reply to Patrick Link to this post

    I appologize for the above question.  It was late and I was tired.  Unfortunately I can't find how I Edit or Delete my original post....

    So, that being said, here is what I hope is a better question about the same concept.

    Looking here --> http://demos.telerik.com/aspnet-mvc/grid/custom-command

    I am trying to figure out how I can have a Custom Command to an Editable window.  I have a subset of data on my Model that I need to be able to Update independently but show cohesively.

     

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 21 Apr Link to this post

    Hello Patrick,

    Unfortunately this is not supported out of the box in the grid widget. However you can achieve it by using some custom code. For example you can have a second command button which opens the build in edit window (by calling editRow() method of the grid), and when this button is clicked you can apply some css classes on the editors inside the window. The css styles can hide some of  the editors.

    The other approach is to have a partial view with edit form which contains editors for some of the grid fields and action which updates the database for a selected record. For example:
    columns.Bound(p => p.ProductName).Width(100).ClientTemplate("<a href='\\#' onclick='return openWindow(this, event);' >Open Window for edit</a>");

    @(Html.Kendo().Window()
        .Name("window")
        .Height(500)
        .Title("Test Window")
        .Visible(false)
        .Draggable()
        .Resizable()   
        .Width(600)
        .Actions(actions => actions.Pin().Minimize().Maximize().Close())
    )

    Then in the openWindow function you can refresh the window and pass the data to the partial view:
    <script type="text/javascript">
        function openWindow(sender, eventArgs) {
            var dataItem = $("#grid").data("kendoGrid").dataItem($(sender).closest("tr"));
            var dialog = $("#window").data("kendoWindow");
     
            dialog.open();
     
            dialog.refresh({
                url: "@Url.Action("Contact", "Home")",
                type: "POST",
                data: { ProductName: dataItem.ProductName }
            });
            return false;
        }
     
    </script>

    The data can be got from the controllers parameters:
    public ActionResult Contact(string ProductName)
            {
                ViewBag.ProductName = ProductName;         
     
                return PartialView("MyPartialView");
            }

    Please give the suggestions try and let me know if you have any question about their implementation.

    Looking forward for your reply.

    Regards,
    Radoslav
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top