0

I'm using KoGrid in order to make my custom Ajax grid.I don't know how to pass model element to some Javascrit method for generating a custom Template.

I tried like this and doesn't work:

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"); });

This is actually a wrapper over KoGrid.I want to pass the data model somehow, to my Js method :

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

When I do like this I received some undefined error of $parent variable.

Please advice,

user_1856538_
  • 149
  • 11
  • `$parent` is defined for use in the HTML `data-bind`, not in the JS code. Can you show the relevant HTML? – Roy J Aug 06 '15 at 10:47
  • Actually I found it:) At the end I created a new html template and put data-bind on html with Js call... – user_1856538_ Aug 06 '15 at 15:20

1 Answers1

0

Finally I found a solution for this:

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

and then

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");

This is the best solution I could find....

user_1856538_
  • 149
  • 11