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

Normalization lost when executing method refresh #93

Closed
jsonantunes opened this issue Mar 27, 2017 · 4 comments
Closed

Normalization lost when executing method refresh #93

jsonantunes opened this issue Mar 27, 2017 · 4 comments
Labels

Comments

@jsonantunes
Copy link

Hello,

Working with a SPA application, For some reason the normalization of fields is lost when executing the refresh method, so the result of the filter is not displayed.

I added a call to the normalization method whenever loadData is executed, and it worked.

My alternate implementation to work around this problem:

`

  let self = this      
  let obj
  let normalizedFields = []
  this.fields.forEach(function(field, i) {
    if (typeof (field) === 'string') {
      obj = {
        name: field,
        title: self.setTitle(field),
        titleClass: '',
        dataClass: '',
        callback: null,
        visible: true,
      }
    } else {
      obj = {
        name: field.name,
        title: (field.title === undefined) ? self.setTitle(field.name) : field.title,
        sortField: field.sortField,
        titleClass: (field.titleClass === undefined) ? '' : field.titleClass,
        dataClass: (field.dataClass === undefined) ? '' : field.dataClass,
        callback: (field.callback === undefined) ? '' : field.callback,
        visible: (field.visible === undefined) ? true : field.visible,
      }
    }

    normalizedFields.push(obj)        
  })

  this.tableFields = normalizedFields
  
}`

Is this really necessary, or am I wrong somewhere?

Translated by google ;)

@ratiw ratiw added the question label Mar 27, 2017
@ratiw
Copy link
Owner

ratiw commented Mar 27, 2017

@johnsoons This looks like the same issue here.

If you dynamically change fields definition, you will need to call normalizeFields, so that the fields definition is properly parsed. This can be done in Vuetable-2 by creating a ref in your <vuetable> tag like so,

  <vuetable ref="vuetable"
    //...
  ></vuetable>

Then, you can call normalizeFields like this

  this.$refs.vuetable.normalizeFields()

@jsonantunes
Copy link
Author

Thanks for the @ratiw return,

It really makes sense to place them dynamically in change fields, however, in the case in question the columns fields are not changed, only the data with the filter result is changed.

@ratiw
Copy link
Owner

ratiw commented Mar 28, 2017

@johnsoons Sorry, I don't quite understand what you mean. Perhaps you could should me the output of the code or error messages.

@jsonantunes
Copy link
Author

Hi @ratiw,

When you first get the data, everything works correctly

id Name Age
1 Janice D. Buckner 20
2 John G. Aragon 31
3 Lynn C. Whitt 40

After filtering, the data is retrieved correctly, however as normalization is lost the columns are added and the data is not listed.

--- --- ---

With the solution I mentioned, this problem in my case solved.

Thanks for listening! :)

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

No branches or pull requests

2 participants