0

I am currently working on a project in DOJO and struck at this point.

I am using dgrid in dojo to generate table and I need to have checkbox in the first column.

Here is Code that is working fine but my requirement is different.

I am taking values for headers and data from a JSON file

Here is the Json file ABC.JSON :

{
"properties": {
    "dataLoading": "full",
    "classNames": ["abc"],
    "autoRefresh": 60,
    "sort" : [ {"attribute":"raiseTime", "decending":true} ]
},
"columns": [
    [[

        { "field":"abc","label":"my label","sortable":true },
        { "field":"def","label":"second label","sortable":true }
    ]],
    [[
        { "field":"fgh", "label":"third label","sortable":true },
        { "field":"ijk", "label":"fourth label","sortable":true }
]]]

}

But to have checkbox feature in table we should have :

var grid = new SelectionGrid({
    columns: [
        selector({ label: '' }),
        { field: 'firstName', label: 'First Name', sortable: false },
        { field: 'lastName', label: 'Last Name', sortable: false }
    ],
    selectionMode: 'none'
}, 'grid');

So, In my JSON I need to call selector() on label. How can I do that in JSON ? Is there any way?

Saddamhussain
  • 860
  • 5
  • 14
sriram
  • 128
  • 12
  • you can call selector() function in formatter property of Dojo column config. you need to pass the name of JS function in formatter property. like in the code below. { field: 'firstName', label: 'First Name', sortable: false formatter:selector}, – Arun Aug 18 '14 at 06:11
  • Its not working @Arun – sriram Aug 18 '14 at 11:38
  • possible duplicate of [Transform Javascript code to JSON and vice versa](http://stackoverflow.com/questions/24265557/transform-javascript-code-to-json-and-vice-versa) – Ken Franqueiro Aug 18 '14 at 22:52
  • As explained by Ken's link above, you need to process the json after it has been received from the server. For example, something like this http://jsfiddle.net/b40d40t0/ ? – Frode Aug 19 '14 at 08:54
  • Try this question http://stackoverflow.com/questions/22428307/dojo-datagrid-dgrid-adding-checkbox-column – Radex Feb 13 '17 at 09:42

0 Answers0