generate event on row button click and add icon? how to

隐身守侯 提交于 2019-12-23 03:07:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!