Вопрос

I need to execute a History push state to some Action on Grid click...

I looked the API, and I think the Events Change its the right place to do that...

So, thats the code i´d like to put in there

"window.History.pushState(null, null," + "'" + Url.Action("Edit", "MyController") + "/' + Id);"

I used that on a similar JS Grid and works fine, but I dont know how to do that with Kendo UI MVC Wrapper... I intend to use that directly on Grid definition, so I dont have to create any JS method... Something like that :

.Events(events => events.Change(x => "window.History.pushState..."))

Is that possible? How get the ID and declare Url.Action there?

Thanks

Это было полезно?

Решение

The docs for the "change" event have an example of how to get the data item for the selected row(s).

The MVC helper expects the string name of a JS function to be passed to events.Change() but I think you can define a function there too.

So something like:

@{
    var url = Url.Action("Edit", "MyController");
}

...

.Events(events => events.Change(x => @"function (changeEvent) {
    var selectedRows = this.select();
    var dataItem;
    var numSelectedRows = selectedRows.length;
    for (var i = 0; i < numSelectedRows ; i++) {
        dataItem = this.dataItem(selectedRows[i]);
        selectedDataItems.push(dataItem);
        window.History.pushState(null, null, """ + url + @"/"" + dataItem.Id);
    }
}"))

I don't have a Kendo MVC project open in front of me to verify the syntax, but that should be pretty close, or at least get you pointed in the right direction.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top