EasyUI Forum
December 14, 2024, 03:32:29 PM *
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 3080 times)
Wojak
Jr. Member
**
Posts: 62


View Profile WWW 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
Jr. Member
**
Posts: 62


View Profile WWW 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!