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

Render the grid without using dataSource #814

Closed
hbjang opened this issue Nov 27, 2019 · 3 comments
Closed

Render the grid without using dataSource #814

hbjang opened this issue Nov 27, 2019 · 3 comments
Assignees
Milestone

Comments

@hbjang
Copy link

hbjang commented Nov 27, 2019

Summary
Grid Paging Data and Server Communication Parameters

Version
v3.3.0/tui-pagination
v1.5.0/tui-code-snippet
v4.7.0/tui-grid

Additional context
I entered the data through the resetData command in the form provided by the document, but the data is not visible in the grid. Please confirm.
grid.resetData(json)
var json = {
"result": true,
"data": {
"contents": [{"file_01":"1, "file_02":"2"}],
"pagination": {
"page": 1,
"totalCount": 1
}
}
};
In addition, please check how to put the parameter.
data: {
api: { readData: { url: '/xxx/xxx/xxx', method: 'GET' }}
},

@auto-comment
Copy link

auto-comment bot commented Nov 27, 2019

Thank you for raising an issue.
We will try and get back to you as soon as possible.

Please make sure you have filled out issue respecting our form in English and given us as much context as possible. If not, the issue will be closed or not replied.

@js87zz js87zz changed the title DataSource를 사용하지 않고 데이터 뿌리기 Render the grid without using dataSource Nov 29, 2019
@js87zz
Copy link
Contributor

js87zz commented Nov 29, 2019

@hbjang

  1. using resetData: You need to pass the array(not object) data with resetData like below
const data = [
  {"file_01":"1, "file_02":"2"}
];
grid.resetData(data)
  1. API: The parameter cannot be added on defining datasource api. we know this is annoying, so have a plan to improve this problem in next release :)

@js87zz js87zz added the 4.x label Dec 24, 2019
@js87zz js87zz added this to the 4.9.0 milestone Jan 15, 2020
@js87zz js87zz self-assigned this Jan 20, 2020
@js87zz
Copy link
Contributor

js87zz commented Feb 3, 2020

@hbjang
DataSource has been improved in v4.9.0(#862)

  1. You can pass initParams to get data
// ...
data: {
  api: {
    // ...
    readData: { 
      url: '/api/oper/user', 
      method: 'GET', 

      // define the parameters to pass on communicating with server to get data initially
      initParams: { params: 'params' }
    },
  }
}
  1. ajax option is extended
const dataSource = {
  hideLoadingBar: true,
  api: {
    readData: { 
      url: '/readData', 
      method: 'get'
    },
    createData: {
      url: '/createData`, 
      method: 'post',

      // define content type for `json`
      contentType: 'application/json',

      // define headers what you want
      headers: { 'x-custom-header': 'x-custom-header' }
    },

    // define custom serializer if you need
    serializer(params) {
      return Qs.stringify(params);
    },

    // You can also define the option in common
    contentType: 'application/json',
    headers: { 'x-custom-header': 'x-custom-header' }
  }
}

Thank you!

@js87zz js87zz closed this as completed Feb 3, 2020
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

2 participants