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

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

2 Answers 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 19 Apr 2016, 03:38 AM

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 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 20 Apr 2016, 10:57 AM

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.

 

0
Radoslav
Telerik team
answered on 21 Apr 2016, 06:39 AM
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
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or