1

我有一个工作网格(字段是名称和 ID):

<grid stuff>
    <kendo:grid-column width="80px">
        <kendo:grid-column-command>
            <kendo:grid-column-commandItem name="delete" text="Delete">
                <kendo:grid-column-commandItem-click>
                //Here I want to grab this worker id and redirect the user to the url workerDelete.html?Id
                </kendo:grid-column-commandItem-click>
            </kendo:grid-column-commandItem>
        </kendo:grid-column-command>
    </kendo:grid-column>
    <kendo:grid-column width="80px">
        <kendo:grid-column-command>
            <kendo:grid-column-commandItem name="update" text="Update">
                <kendo:grid-column-commandItem-click>
                    // here I want to grab this worker id and redirect the user to the url workerUpdate.html?Id
                </kendo:grid-column-commandItem-click>
            </kendo:grid-column-commandItem>
        </kendo:grid-column-command>
    </kendo:grid-column>
</grid stuff>  

我需要知道当用户按下自定义按钮并更改视图时如何从行中捕获数据,并将数据传递到查询字符串上。我正在使用jsp和spring。

我尝试使用以下代码,但没有奏效:

<script>
    function deleteWorker() {
        var grid = $('#grid').data('kendoGrid');
        var row = grid.dataItem(grid.select());
        var id = row.id;
        window.location.href = "/workerDelete.html?"+cpf; 
    }
</script>
4

2 回答 2

2

您需要定义grid-column-command如下:

<kendo:grid-column-command>
    <kendo:grid-column-commandItem name="update" text="Update" click="deleteWorker"/>
</kendo:grid-column-command>

deleteWorker功能为:

    function deleteWorker(e) {
        var tr = $(e.currentTarget).closest("tr");
        var item = $("#grid").data("kendoGrid").dataItem(tr);
        // Do whatever else you need
    }

在这个功能item是剑道网格dataItem

于 2013-01-24T18:36:16.997 回答
0

使用模板列。模板可以是一个用k-button 类装饰的按钮(所以它看起来像一个剑道按钮)和自定义类,如deleteWorker类。

然后您可以在初始化网格时添加委托事件处理程序,例如:

$('#gridName').on('click','.deleteWorker',function(){
    var tr = $(this).closest('tr');
    var rowItem = grid.dataItem(tr);
    var id = rowItem.id;
    window.location.href = "/workerDelete.html?"+id;
})
于 2013-01-24T17:25:45.707 回答