javascriptjquery-easyui

EasyUI Datagrid with two identical fields and diffrent formatter


I have an EasyUI Datagrid with two identical fields like this :

<th data-options="field:'listprice',width:80,align:'right',formatter:formatPrice">List Price</th>

<th data-options="field:'listprice',width:80,align:'right',formatter:formatPriceToWords">List Price</th>

and I have 2 functions for formatting price value but for these columns, just the formatter of the first column is applying. I have a jsfiddlethat shows exactly the problem and here is the link :

http://jsfiddle.net/pouya_devil/vrbjudpz/2/

if you comment the first column with the listprice field then the second formatter Function will apply. I want to know how can implement the grid with 2 columns identical field


Solution

  • Both columns are referencing to the same field. Unfortunatly the docs are not clear about such a situation, but this seems to be an issue.

    To solve this you could introduce another row-element in your 'griddata' which duplicates the listprice.

    I've forked your fiddle to clearify this: http://jsfiddle.net/zwif_/ncjperwm/