Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to read JSON value from dataSource API #2033

Open
chzh2839 opened this issue Apr 18, 2024 · 0 comments
Open

how to read JSON value from dataSource API #2033

chzh2839 opened this issue Apr 18, 2024 · 0 comments

Comments

@chzh2839
Copy link

Version : ^4.21.21

Development Environment : Windows OS, Chrome browser, React, Typescript

Current Behavior

I tried to use specific value of JSON , which is from dataSource API, in Grid.
But, 'Property does not exist' error message is shown up.

The api response data type sample is below:

{
        'key1': 'value1',
        'key2': 'value2',
        'key3': [
            {'options-child1': 'value3'}, 
            {'options-child2': 'value4'}
        ],
       'key4': {
           'children': 'value5'
        }
      },

I use as below :
CASE 1 ) using in 'name'

{
        header: 'gridColumnName',
        name: 'key4.children',
        align: 'center',
},

=> I can't make show up 'value5' text on Grid. It shows empty value..

CASE 2 ) trying to use 'OnClick'

const handleClick = useCallback(
    ({ targetType, columnName, instance, rowKey }: GridEvent) => {
      const rowKey_key3 = instance.getValue(rowKey, 'key3') //   on Console, rowKey_key3 shows '[object Object],[object Object]'.

     const array = Array.from(rowKey_key3 as string)
     array.forEach(ele => {
        console.log(`ele : ${ele.options-child1 as string}`) // this is error point
      })
    },
    []
  )

=> I can't get 'options-child1' value...

I want to know how to handle JSON data with multiple depth, in Tui-Grid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant