Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #100759
    admin
    Keymaster

    Hello,
    I have a question concerning data fields in the dataAdapter. I have an json object used as source by the adapter that looks like this:

    {
    text: 'text',
    object:
    {
    text2:'text2'
    }
    }

    I didn’t found an opportunity to select text2 as datafield. In JQWidgets there was away to map a datafield to solve this problem. Is there something like that in Smart Html Elements?

    #100760
    admin
    Keymaster

    Hi Gerhard Seemann,
    Have you tried it by defining the dataFields array as in our jqxDataAdapter like that { name: …, map: …. } The map field defines the sub property mapping.
    Regards,
    Peter
    Smart UI Team
    https://www.htmlelements.com/

    #100763
    admin
    Keymaster

    Hi Peter,
    defining the dataFields like that didn’t work for me in the Smart.DataAdapter. Even without the mapping. The only way it worked for me was

    dataFields: [
    'name:type',
    'name:type'
    ]

    But I don’t see a way to do the mapping defining it like that.
     
    Regards,
    Gerhard

    #100764
    admin
    Keymaster

    Hi Gerhard,
    Did you follow my suggestion? Could you share codepen sample which shows how you tried to define a dataAdapter with dataFields mapping?
    Regards,
    Peter
    Smart UI Team
    https://www.htmlelements.com/

    #100765
    admin
    Keymaster

    Hi,
    yeah I followed your suggestion. I tried it without mapping and with mapping. Both doesn’t work.
    Here it is without mapping:
    https://codepen.io/captaingerhard/pen/ExVGEKW?editors=0010
    And here it is with mapping:
    https://codepen.io/captaingerhard/pen/WNQLzyQ?editors=0010
     
    Regards,
    Gerhard

    #100766
    admin
    Keymaster

    Hi Gerhard,
    You can use this:

       dataSource: new Smart.DataAdapter({
    dataSource: data,
    dataFields: [
    {name: 'text1', dataType: 'string'},
    {name: 'object', dataType: 'string'}
    ]
    }),
    columns: [
    { label: 'Text 1', dataField: 'text1' },
    { label: 'Object', dataField: 'object' },
    ]

    Regards,
    Peter
    Smart UI Team
    https://www.htmlelements.com/

    #100767
    admin
    Keymaster

    Hi Peter,
    thank you! Now I can define it like that. But it doesn’t solve my mapping problem.
    https://codepen.io/captaingerhard/pen/WNQLzyQ?editors=0010
    Is the attribute ‘map’ wrong, too?
     
    Regards,
    Gerhard

    #100768
    admin
    Keymaster

    Hi Gerhard,
    With mapping, you can use:

    var data = [
    {text1: 'abcde', object: {num1: 123}},
    {text1: 'abcde', object: {num1: 123}},
    {text1: 'abcde', object: {num1: 123}},
    {text1: 'abcde', object: {num1: 123}},
    {text1: 'abcde', object: {num1: 123}}
    ];
    Smart('#grid', class {
    get properties() {
    return {
    dataSource: new Smart.DataAdapter({
    mapChar: '.',
    dataSource: data,
    dataFields: [
    {name: 'text1', dataType: 'string'},
    {name: 'num1', map: 'object.num1', dataType: 'number'}
    ]
    }),
    columns: [
    { label: 'Text 1', dataField: 'text1' },
    { label: 'Number', dataField: 'num1' },
    ]
    }
    }
    });

    Hope this helps.
    Regards,
    Peter
    Smart UI Team
    https://www.htmlelements.com/

    #100769
    admin
    Keymaster

    Hi,
    yes that helped. Thank you a lot!
    Best regards,
    Gerhard

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