EasyUI Forum
March 04, 2024, 01:02:03 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [Solved] Adding columns dynamically with formatter and styler as string  (Read 771 times)
Wojak
Newbie
*
Posts: 45


View Profile Email
« on: July 20, 2023, 11:03:49 AM »

Hi,
How could I solve my problem? I tried eval(); and (function() {})();

Code
Code:
function refreshDatagrid() {
    const columns = $('#datalist').datalist('getRows');
    $('#datagrid').datagrid({ columns: [columns] });
}

Data
Code:
[
    {
        "field": "field_fdqzv",
        "title": "title"
    },
    {
        "field": "field_2agdu",
        "title": "2agdu",
        "_selected": true,
        "width": 200,
        "align": "center",
        "formatter": "function (value, row, index) {\n\treturn value + ' ' + index;\n}",
        "styler": ""
    }
]
« Last Edit: July 23, 2023, 12:58:35 PM by Wojak » Logged
Wojak
Newbie
*
Posts: 45


View Profile Email
« Reply #1 on: July 23, 2023, 12:59:23 PM »

JSONfn comes with the answer

Code:
$('#datagrid').datagrid({ columns: [JSONfn.parse(JSONfn.stringify(columns))] });
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!