问题
Here is my HTML code:
<div id="grdCurrencies"
data-selectable="true"
data-role="grid"
data-pageable=" true"
data-sortable=" true"
data-columns='[
{ "field": "CurrencyCode", "width": 100 },
{ "field": "CurrencyName", "width": 100 } ,
{ field:"", template:"<i "class=" fa fa-trash-o grid-icon" data-bind="click: destroy"">del<"/"i>" , "width":40 }]'
data-bind="source: dsProduct, events: {change: OnGridActiveRowChanged} "
style=" height :500px;width:35%;">
</div>
In the template
field:<a >del<a>
, I have to add an icon and also have to fire an event on-clicking icon for that in the link. I have to give class and event name on-click. How would I accomplish this?
回答1:
Add data-template="mytemplate"
attribute in grid and following is the sample code of template. This might do the trick
<script id="mytemplate" type="text/x-kendo-template">
<tr>
<td data-bind="text:CurrencyCode"></td>
<td data-bind="text:CurrencyName"></td>
<td class="text-center" width="13%">
<i class="fa fa-trash-o" data-bind="click: removeRec"></i>
</td>
</tr>
</script>
来源:https://stackoverflow.com/questions/31137571/generate-event-on-row-button-click-and-add-icon-how-to