Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #101424
    dusrkdldlr
    Member

    hello!
    I want to use the value of an array in json.
    It is returned as [object Object], how can I get this value?
    This is example
    :json

    
    {
    "enabled": true,
    "tests": [
    1
    ],
    "school": {
    "content": [
    {
    "id": "1",
    "no": "1",
    "class": 1,
    "name": "ge1",
    "tags": [
    ],
    "group": [
    {
    "id": 1,
    "no": 1,
    "priority": 128,
    }
    ],
    "number_of_elements": 10,
    "first": true
    }
    }
    

    get json

    
    <div>
    <div>if(details.action === 'dataBind' ){</div>
    <div>                                    fetch(<code>test.json</code>,{</div>
    <div>                                      method: 'POST',</div>
    <div>                                      body: paramData</div>
    <div>                                    }).then(response => response.json())</div>
    <div>                                      .then(data => {</div>
    <div>                                        const result = data;</div>
    <div>                                        console.log("this is result", result);</div>
    <div>                                        resultCallbackFunction({</div>
    <div>                                          dataSource: result.school.content,</div>
    <div>                                          virtualDataSourceLength: result.school.total_elements</div>
    <div>                                        });</div>
    <div>                                      });//fetch</div>
    </div>
    

    columns

    
    <div>
    <div>,{label: priority, dataField: "groip", visible: false,template: function(formatObject){</div>
    <div>       console.log("length?", formatObject.row.data.groupObject.length)</div>
    <div>       var groupObject = formatObject.row.data.group;</div>
    <div>       for (var key in groupObject){</div>
    <div>          console.log("key: " +  key + "value" +groupObject[key])</div>
    <div>      }  } }</div>
    </div>
    

    log

    
    length? 15
    key: 0value[
    key: 1valueo
    key: 2valueb
    key: 3valuej
    key: 4valuee
    key: 5valuec
    key: 6valuet
    key: 7value
    key: 8valueO
    key: 9valueb
    key: 10valuej
    key: 11valuee
    key: 12valuec
    key: 13valuet
    key: 14value]
    

    I wan’t use group.priority. but This value is returned as [object Object].

    #101428
    admin
    Keymaster

    Hi,
    Unfortunately, we do not understand what you are trying to achieve. The data binding options of our DataGrid component are demonstrated https://www.htmlelements.com/demos/ in the Data Binding and Server-side Model sections.
    Best regards,
    Peter Stoev
    Smart UI Team
    https://www.htmlelements.com/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.