0

我正在使用KoGrid来制作我的自定义 Ajax 网格。我不知道如何将模型元素传递给一些 Javascrit 方法以生成自定义模板。

我试过这样但不起作用:

PluginGrid.AjaxUrl("MyControler/GetGrid").Columns( [ { field: "UserName", displayName: "Model", width: "*", cellClass: "text-center", headerClass: "grid_width_270", cellTemplate: PluginHelpers.HtmlUserInformation($parent.entity, true) }, { field: "StatusId", displayName: "Status", width: "*", cellClass: "text-center", headerClass: "text-center" } ]).Show("grid"); });

这实际上是 KoGrid 的包装器。我想以某种方式将数据模型传递给我的 Js 方法:

 PluginHelpers.HtmlUserInformation($parent.entity, true) }

当我这样做时,我收到了 $parent 变量的一些未定义错误。

请指教,

4

1 回答 1

0

最后我找到了一个解决方案:

<template id="XXX"> <div data-bind="html: PluginHelpers.HtmlUserInformation($parent.entity, true)"> </div> </template>

接着

PluginGrid.AjaxUrl("Controller/GetGrid").Columns( [ { field: "UserName", displayName: "Model", width: "*", cellClass: "text-center", headerClass: "grid_width_270", cellTemplate: $("#XXX").html() }, { field: "StatusId", displayName: "Status", width: "*", cellClass: "text-center", headerClass: "text-center" } ]).Show("grid");

这是我能找到的最好的解决方案......

于 2015-08-06T15:29:55.250 回答