eisenbraun / columns

A jQuery plugin that converts JSON data into searchable, sortable, HTML tables
http://eisenbraun.github.io/columns
MIT License
104 stars 47 forks source link

switching content #2

Closed oceatoon closed 5 years ago

oceatoon commented 10 years ago

Hi first thanks for the great lib , it's very clean and functionnal I have my data loaded in $('#columns') but some user action will get new data so I need to reload my table's content Itried this $('#columns').columns('setMaster', newData); and reset but neither work

I'm probably not doing it right please shed some light Thanks

eisenbraun commented 10 years ago

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

oceatoon commented 10 years ago

cool thanks for the quick response is there a way, to know if a given ID already hascolumn active something like $(id).columns("active") > boolean

On Wed, Jul 9, 2014 at 9:29 PM, eisenbraun notifications@github.com wrote:

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48506815.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

oceatoon commented 10 years ago

let me explain what I'm doing I have a div id="mydata" my 1st button fills it with data , as columns I then have a 2nd button the show replaces the html of mydata by the json value and when I want to reclick on the 1st it should show the colmuns version again

The 2 first work fine but doesn't work when I want to redraw the data as columns Thanks Tibor

On Thu, Jul 10, 2014 at 12:21 PM, Tibor Katelbach oceatoon@gmail.com wrote:

cool thanks for the quick response is there a way, to know if a given ID already hascolumn active something like $(id).columns("active") > boolean

On Wed, Jul 9, 2014 at 9:29 PM, eisenbraun notifications@github.com wrote:

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48506815.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

oceatoon commented 10 years ago

I found I could simply use if($(id).hasClass("columns")) to check if columns was allready generated previously but still I do this $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); but doesn't work

here's my method construction works fine resetMaster doesn't work

function showAsColumn(resp,id){ if($(id).hasClass("columns")) { $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); } else { $(id).columns({ data:Object2Array(resp) }); } }

On Thu, Jul 10, 2014 at 12:26 PM, Tibor Katelbach oceatoon@gmail.com wrote:

let me explain what I'm doing I have a div id="mydata" my 1st button fills it with data , as columns I then have a 2nd button the show replaces the html of mydata by the json value and when I want to reclick on the 1st it should show the colmuns version again

The 2 first work fine but doesn't work when I want to redraw the data as columns Thanks Tibor

On Thu, Jul 10, 2014 at 12:21 PM, Tibor Katelbach oceatoon@gmail.com wrote:

cool thanks for the quick response is there a way, to know if a given ID already hascolumn active something like $(id).columns("active") > boolean

On Wed, Jul 9, 2014 at 9:29 PM, eisenbraun notifications@github.com wrote:

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48506815.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

oceatoon commented 10 years ago

as usual it was my mistake all is working great now cheers Tibor

On Thu, Jul 10, 2014 at 2:01 PM, Tibor Katelbach oceatoon@gmail.com wrote:

I found I could simply use if($(id).hasClass("columns")) to check if columns was allready generated previously but still I do this $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); but doesn't work

here's my method construction works fine resetMaster doesn't work

function showAsColumn(resp,id){ if($(id).hasClass("columns")) { $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); } else { $(id).columns({ data:Object2Array(resp) }); } }

On Thu, Jul 10, 2014 at 12:26 PM, Tibor Katelbach oceatoon@gmail.com wrote:

let me explain what I'm doing I have a div id="mydata" my 1st button fills it with data , as columns I then have a 2nd button the show replaces the html of mydata by the json value and when I want to reclick on the 1st it should show the colmuns version again

The 2 first work fine but doesn't work when I want to redraw the data as columns Thanks Tibor

On Thu, Jul 10, 2014 at 12:21 PM, Tibor Katelbach oceatoon@gmail.com wrote:

cool thanks for the quick response is there a way, to know if a given ID already hascolumn active something like $(id).columns("active") > boolean

On Wed, Jul 9, 2014 at 9:29 PM, eisenbraun notifications@github.com wrote:

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48506815.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

oceatoon commented 10 years ago

the content changing works fine but if by any chance I add a column to the dataset the setMaster doesn't add it, is there a way to destroy and rebuild ?

On Thu, Jul 10, 2014 at 2:09 PM, Tibor Katelbach oceatoon@gmail.com wrote:

as usual it was my mistake all is working great now cheers Tibor

On Thu, Jul 10, 2014 at 2:01 PM, Tibor Katelbach oceatoon@gmail.com wrote:

I found I could simply use if($(id).hasClass("columns")) to check if columns was allready generated previously but still I do this $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); but doesn't work

here's my method construction works fine resetMaster doesn't work

function showAsColumn(resp,id){ if($(id).hasClass("columns")) { $(id).columns('setMaster', Object2Array(resp)); $(id).columns('create'); } else { $(id).columns({ data:Object2Array(resp) }); } }

On Thu, Jul 10, 2014 at 12:26 PM, Tibor Katelbach oceatoon@gmail.com wrote:

let me explain what I'm doing I have a div id="mydata" my 1st button fills it with data , as columns I then have a 2nd button the show replaces the html of mydata by the json value and when I want to reclick on the 1st it should show the colmuns version again

The 2 first work fine but doesn't work when I want to redraw the data as columns Thanks Tibor

On Thu, Jul 10, 2014 at 12:21 PM, Tibor Katelbach oceatoon@gmail.com wrote:

cool thanks for the quick response is there a way, to know if a given ID already hascolumn active something like $(id).columns("active") > boolean

On Wed, Jul 9, 2014 at 9:29 PM, eisenbraun notifications@github.com wrote:

You're very welcome. I glad you like it.

After you use 'setMaster':

$('#columns').columns('setMaster', newData);

you need to recreate the table for the new data to be displayed:

$('#columns').columns('create');

This is not documented, sorry about that. I will be sure to add it to the documentation during the next update.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48506815 .

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

eisenbraun commented 10 years ago

There isn't a method to destroy table. I will definitely add one in the next release. But until then here is what you can do.

Clear the all data associated with the selector:

$(id).data('columns', null);

With the data cleared you will be able to reintialize the table with data and settings

$(id).columns({data:json});

I hope that helps, and let me know if you have any questions.

oceatoon commented 10 years ago

Hi Michael unfortunetly that didn't work either I'll wait for the next release Cheers Tibor

On Fri, Jul 11, 2014 at 12:38 AM, Michael Eisenbraun < notifications@github.com> wrote:

There isn't a method to destroy table. I will definitely add one in the next release. But until then here is what you can do.

Clear the all data associated with the selector:

$(id).data('columns', null);

With the data cleared you will be able to reintialize the table with data and settings

$(id).columns({data:json});

I hope that helps, and let me know if you have any questions.

— Reply to this email directly or view it on GitHub https://github.com/eisenbraun/columns/issues/2#issuecomment-48660851.

Tibor Katelbach – Senior Developper http://oceatoon.org ..·><((((º>·´¯`·.¸¸..><((((º>.¸¸..·.¸¸..><((((º>.¸¸.. La Riviere, La Reunion e-mail : oceatoon@gmail.com skype : oceatoon Fixe : +262+262343686 Mobile : +262-693918532

Save a tree...please don't print this e-mail unless you really need to.

xjsender commented 9 years ago

@oceatoon , if I try to destroy columns by $('#columns').columns('destroy'); before use new content, I will get this message No such method "destroy" for Columns, however, If I use $('#columns').data('columns', null); to replace it, it will be ok.

I used the latest version of this plugin.