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

服务端数据模式 数据初始化异常 #60

Open
AgentZh0u opened this issue May 27, 2021 · 2 comments
Open

服务端数据模式 数据初始化异常 #60

AgentZh0u opened this issue May 27, 2021 · 2 comments

Comments

@AgentZh0u
Copy link

官网的样例,在data 本地模式中,v-model绑定的数据,在select框初始化时会呈现数据,但是用 :data 服务端数据模式下,v-model绑定的数据初始化会出现异常

@AgentZh0u
Copy link
Author

image
remote (initPicked = false) { if (typeof this.data === 'string' && this.dataLoad && typeof this.dataLoad === 'function') { const queryParams = this.params && Object.keys(this.params).length ? JSON.parse(JSON.stringify(this.params)) : {} queryParams.pageSize = this.pageSize queryParams.pageNumber = this.pageNumber if (this.sort) queryParams.orderBy = this.sort if (initPicked && this.value) { queryParams.searchKey = this.keyField queryParams.searchValue = this.value } if (this.search) { // this.searchField ? this.searchField : this.showField; if (!this.searchField && typeof this.showField === 'function') { // eslint-disable-next-line no-console console.error('Your "showField" was a function, in server side mode, your need specified "searchField" to search content.') } else { const field = this.searchField || this.showField queryParams[field] = this.search } } this.dataLoad(this, this.data, queryParams).then(resp => { if (resp) { if (!this.resultFormat || typeof this.resultFormat !== 'function') { // eslint-disable-next-line no-console console.error('In server side mode, you need specified "result-format" option(function type) to format server side response result.') } else { const tmpObj = this.resultFormat(resp) if (tmpObj && Object.keys(tmpObj).length) { if (!initPicked) { // load new page data list this.list = tmpObj.list this.totalRows = tmpObj.totalRow } else { // this.picked = tmpObj.list if (tmpObj.list != null && tmpObj.list != '' && Array.isArray(tmpObj.list)) { const arr = this.value.split(',') if (arr && arr.length) { const matchRows = tmpObj.list.filter(val => arr.includes(String(val[this.keyField]))) if (matchRows.length) { this.picked = this.multiple ? matchRows : [matchRows[0]] } } } }// the selected item info } } } }).catch(resp => { this.list = [] this.totalRows = 0 }) } }

我这么改的,目前是解决了

@acanthis
Copy link

acanthis commented Jun 9, 2021

image
remote (initPicked = false) { if (typeof this.data === 'string' && this.dataLoad && typeof this.dataLoad === 'function') { const queryParams = this.params && Object.keys(this.params).length ? JSON.parse(JSON.stringify(this.params)) : {} queryParams.pageSize = this.pageSize queryParams.pageNumber = this.pageNumber if (this.sort) queryParams.orderBy = this.sort if (initPicked && this.value) { queryParams.searchKey = this.keyField queryParams.searchValue = this.value } if (this.search) { // this.searchField ? this.searchField : this.showField; if (!this.searchField && typeof this.showField === 'function') { // eslint-disable-next-line no-console console.error('Your "showField" was a function, in server side mode, your need specified "searchField" to search content.') } else { const field = this.searchField || this.showField queryParams[field] = this.search } } this.dataLoad(this, this.data, queryParams).then(resp => { if (resp) { if (!this.resultFormat || typeof this.resultFormat !== 'function') { // eslint-disable-next-line no-console console.error('In server side mode, you need specified "result-format" option(function type) to format server side response result.') } else { const tmpObj = this.resultFormat(resp) if (tmpObj && Object.keys(tmpObj).length) { if (!initPicked) { // load new page data list this.list = tmpObj.list this.totalRows = tmpObj.totalRow } else { // this.picked = tmpObj.list if (tmpObj.list != null && tmpObj.list != '' && Array.isArray(tmpObj.list)) { const arr = this.value.split(',') if (arr && arr.length) { const matchRows = tmpObj.list.filter(val => arr.includes(String(val[this.keyField]))) if (matchRows.length) { this.picked = this.multiple ? matchRows : [matchRows[0]] } } } }// the selected item info } } } }).catch(resp => { this.list = [] this.totalRows = 0 }) } }

我这么改的,目前是解决了

if the data is on another page it will not work :(
could you post the client code when working with data from the server side?

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

No branches or pull requests

2 participants