Giter Site home page Giter Site logo

Settings property update about ng2-smart-table HOT 9 CLOSED

akveo avatar akveo commented on May 13, 2024 1
Settings property update

from ng2-smart-table.

Comments (9)

nnixaa avatar nnixaa commented on May 13, 2024 1

@geneeblack now this should work as you described, you can pass the whole settings object with the changes you need and it will be merged on top of the default settings object.

from ng2-smart-table.

nnixaa avatar nnixaa commented on May 13, 2024

@geneeblack yeah, this is a regression issue from this commit 2ebac0f, will have a look soon.

from ng2-smart-table.

nnixaa avatar nnixaa commented on May 13, 2024

guys, could you try latest changes from master and let me know if everything works as expected? Thanks.

from ng2-smart-table.

geneeblack avatar geneeblack commented on May 13, 2024

The way I was using settings was to send a partial description of new settings, i.e.

settings = {
actions: {
edit:false,
delete: false,
update: false
columns: {...}
}

I can see in #15 that they may have been attempting to set the settings.columns directly on the settings property rather than the assigning the whole settings property. I can see where this wouldn't work because it is not triggering the settings change. Maybe some type of general accessor 'set(propertykey) that would then trigger the property change might be middle ground where individual properties in settings could be changed while still triggering the change. Otherwise you could strong type the settings object and have onchange for each element. Although I am happy to send the whole settings object with only those differences that I wish to change from the default as long as those settings are overlaid on top of the defaults i.e. deepcopy(defaults, mysettings).

from ng2-smart-table.

jkon avatar jkon commented on May 13, 2024

If I am understanding this right, you are only talking about when you pass the settings object into the component in the view template. What if I wanted to make a change to the table with a settings property after the view is rendered? For example, if I have a button bound to a function in my component that I want to hide the sub header, would I do it like this:
toggleSubHeader() {
console.log('you toggled the sub header');
this.settings.hideSubHeader = !this.settings.hideSubHeader;
}

or do I need to then pass the settings into the smart table component again somehow?

from ng2-smart-table.

legrosbill avatar legrosbill commented on May 13, 2024

@jkon Hi, have the same question, this way don't seems to work for me , have you find a solution ?

from ng2-smart-table.

legrosbill avatar legrosbill commented on May 13, 2024

unfortunately, you have to change this.settings to trigger onChanges event (it's a global angular2 binding issue)
so the right way is :
toggleSubHeader() {
console.log('you toggled the sub header');
this.settings = {
hideSubHeader:!this.settings.hideSubHeader
};
}

from ng2-smart-table.

jkon avatar jkon commented on May 13, 2024

I had a lot of other customizations that I wanted to do with this package so I made a copy of the repo locally and exposed the initGrid() function. Probably not smartest way, but it allows me to make all the changes I want.

from ng2-smart-table.

kmanship avatar kmanship commented on May 13, 2024

Not a fan of this approach as it involves jQuery, but use jQuery to find the smart filters and wire up a button to trigger the toggle.

  constructor(@Inject(JQUERY_TOKEN) private $: any) {}

  public toggleFilter() {
    const filterRow = this.$('.ng2-smart-filters');
    this.hideSubHeader = !this.hideSubHeader;
    this.hideSubHeader ? filterRow.hide() : filterRow.show();
  }

from ng2-smart-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.