Title: [Solved] Using Formatter in JSON object with Datagrids Post by: Darrel on December 14, 2015, 12:05:34 AM Hello,
I was trying to use the formatter property to create a hyperlink for the first column of the datagrid. I tried referring to the following links: http://www.jeasyui.com/forum/index.php?topic=4585.0 (http://www.jeasyui.com/forum/index.php?topic=4585.0) http://www.jeasyui.com/forum/index.php?topic=5268.0 (http://www.jeasyui.com/forum/index.php?topic=5268.0) http://www.jeasyui.com/forum/index.php?topic=3486.0 (http://www.jeasyui.com/forum/index.php?topic=3486.0) But they didn't help me out much. I only need the formatter to work for the first column only, i.e, i want the hyperlink to be visible in the first column only. Below are the changes that i've carried out to achieve the same, but failed due to a script error. This is my JSON object that is created after the ajax call: Code: {"COL_LIST":{"COL_DATA":[{"field":"col_0","title":"Client Code","formatter":"createLink"},{"field":"col_1","title":"Client"},{"field":"col_2","title":"Account"},{"field":"col_3","title":"Type Code"},{"field":"col_4","title":"Client Id"},{"field":"col_5","title":"Type"}]},"ROW_LIST":{"ROW_DATA":[{"col_0":"ROW0A03","col_1":"ABC DEBIT FUND","col_2":"A03","col_3":"ABCD","col_4":"6565","col_5":"AUTHORIZED"},{"col_0":"ROW1A03","col_1":"ABC DEBIT FUND","col_2":"A03","col_3":"EFGH","col_4":"17869","col_5":"AUTHORIZED"}]}} The following code is written in my html page: Code: <TABLE id="RESULTS_TABLE"></TABLE> The following code is written in the javascript block: Code: function createLink(value,row,extra) I get a script error stating "function expected". Is it something that I'm doing wrongly in the JSON string???? Thanks in advance! Regards, Darrel Title: Re: Using Formatter in JSON object with Datagrids Post by: stworthy on December 14, 2015, 06:17:42 AM The 'formatter' should be a function not a string, please convert it to a function before creating the datagrid.
Code: function createDataGrid(data) Title: Re: Using Formatter in JSON object with Datagrids Post by: Darrel on December 14, 2015, 09:04:05 PM Thanks a lot stworthy,
It worked using the sample lines you gave. :) Regards, Darrel. |