filtered table with checkboxes - problem

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

filtered table with checkboxes - problem

danovics
Hi

I made a filtered table. In the first column I have checkboxes. I append an event listener to the table "cellclick" because I want to change the checkboxes values "on the fly". Everything seemed to work properly untill I started to filtering the table's rows depending on the checkboxes' value.

Something silly is going on but I can't figure out what is it.
1. After the application starts I build the table and define 3 buttons (checked, unchecked, all).
2. Then I change some of the checkboxes.
3/a. If I click button "All" (tableModel.resetHiddenRows();) all checkboxes changes back to the init value, they just loose the new values.
3/b. If I click one of the another two buttons (Checked or Unchecked: tableModel.addNumericFilter("!=", 1, "checkbox"); or tableModel.addNumericFilter("==", 1, "checkbox");) the filtering works fine. But after clicking on All and after that changing the cb values, this values will be forgotten after clicking again on All.

The example code could be downloaded from here:
http://dl.dropbox.com/u/5843/code/qx/Application.js

It's the third day that I could not find the solution for this problem :(
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Stefan Volbers
Hi danovics,

looking at table/model/filtered.js, I believe it's a bug in Filtered.
Whenever resetHiddenRows() is called, a shadow table data
(this.__fullArr) is retrieved; but this would be set correctly only if
you used setData() in your application, the setRows() method seems to
have been forgotten. Therefore the shadow data isn't updated, and when
it is recalled within resetHiddenRows(), you get outdated data.
So, if my guess is right, a workaround would be to use setData() in your
cellClick listener (haven't tried myself).

Dan is the author of the filtered model, maybe he can comment on that?

HTH,
greetings,
Stefan

danovics wrote:

> Hi
>
> I made a filtered table. In the first column I have checkboxes. I append an
> event listener to the table "cellclick" because I want to change the
> checkboxes values "on the fly". Everything seemed to work properly untill I
> started to filtering the table's rows depending on the checkboxes' value.
>
> Something silly is going on but I can't figure out what is it.
> 1. After the application starts I build the table and define 3 buttons
> (checked, unchecked, all).
> 2. Then I change some of the checkboxes.
> 3/a. If I click button "All" (tableModel.resetHiddenRows();) all checkboxes
> changes back to the init value, they just loose the new values.
> 3/b. If I click one of the another two buttons (Checked or Unchecked:
> tableModel.addNumericFilter("!=", 1, "checkbox"); or
> tableModel.addNumericFilter("==", 1, "checkbox");) the filtering works fine.
> But after clicking on All and after that changing the cb values, this values
> will be forgotten after clicking again on All.
>
> The example code could be downloaded from here:
> http://dl.dropbox.com/u/5843/code/qx/Application.js
>
> It's the third day that I could not find the solution for this problem :(

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
Thank you _very_ much for your answer.
It's good to know, that is not me or my code make the mistake.
Although I didn't understand 100% what you wrote, but I'll try the method you suggested.
Thanks again.
 
Stefan Volbers wrote
Hi danovics,

looking at table/model/filtered.js, I believe it's a bug in Filtered.
Whenever resetHiddenRows() is called, a shadow table data
(this.__fullArr) is retrieved; but this would be set correctly only if
you used setData() in your application, the setRows() method seems to
have been forgotten. Therefore the shadow data isn't updated, and when
it is recalled within resetHiddenRows(), you get outdated data.
So, if my guess is right, a workaround would be to use setData() in your
cellClick listener (haven't tried myself).

Dan is the author of the filtered model, maybe he can comment on that?

HTH,
greetings,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
In reply to this post by Stefan Volbers
I looked up in the Api and I found that using setData() instead of setRow() is very very much slower because on every single click on a checbox-cell I have to change the content of the whole table (which could be pretty huge). It is a little bit annoying.
I dont know if does exist another solution for this problem, but it would be very nice.

I'm waiting for Dan's reply.
Greetings to all.

Stefan Volbers wrote
Hi danovics,

looking at table/model/filtered.js, I believe it's a bug in Filtered.
Whenever resetHiddenRows() is called, a shadow table data
(this.__fullArr) is retrieved; but this would be set correctly only if
you used setData() in your application, the setRows() method seems to
have been forgotten. Therefore the shadow data isn't updated, and when
it is recalled within resetHiddenRows(), you get outdated data.
So, if my guess is right, a workaround would be to use setData() in your
cellClick listener (haven't tried myself).

Dan is the author of the filtered model, maybe he can comment on that?

HTH,
greetings,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Stefan Volbers
In reply to this post by danovics
Inspired by your friendly answer, I further looked into this.

Can someone confirm if this patch for qx/ui/table/model/Filtered.js
resolves the mentioned problem (assuming qooxdoo-0.8.3-sdk)?

410a411,419
 >     },
 >
 >
 >     // overridden
 >     setRows : function(rowArr, startIndex, clearSorting)
 >     {
 >       this.Filters = [];
 >       this.base(arguments, rowArr, startIndex, clearSorting);
 >       this.__fullArr = qx.lang.Array.clone(this.getData());

If it does, same means would have to be applied to other data setting
methods (at least setRowsAsMapArray() - are there others?).

Greetings,
Stefan

danovics wrote:

> Thank you _very_ much for your answer.
> It's good to know, that is not me or my code make the mistake.
> Although I didn't understand 100% what you wrote, but I'll try the method
> you suggested.
> Thanks again.
>  
>
> Stefan Volbers wrote:
>> Hi danovics,
>>
>> looking at table/model/filtered.js, I believe it's a bug in Filtered.
>> Whenever resetHiddenRows() is called, a shadow table data
>> (this.__fullArr) is retrieved; but this would be set correctly only if
>> you used setData() in your application, the setRows() method seems to
>> have been forgotten. Therefore the shadow data isn't updated, and when
>> it is recalled within resetHiddenRows(), you get outdated data.
>> So, if my guess is right, a workaround would be to use setData() in your
>> cellClick listener (haven't tried myself).
>>
>> Dan is the author of the filtered model, maybe he can comment on that?
>>
>> HTH,
>> greetings,
>> Stefan
>>
>>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
Actually I'm trying the removeRows(), addRows() method-combination. It seems to be a little bit faster than change all the datas.
I'll write my experiences with this.

Greetings
Daniel
 
Stefan Volbers wrote
Inspired by your friendly answer, I further looked into this.

Can someone confirm if this patch for qx/ui/table/model/Filtered.js
resolves the mentioned problem (assuming qooxdoo-0.8.3-sdk)?

410a411,419
 >     },
 >
 >
 >     // overridden
 >     setRows : function(rowArr, startIndex, clearSorting)
 >     {
 >       this.Filters = [];
 >       this.base(arguments, rowArr, startIndex, clearSorting);
 >       this.__fullArr = qx.lang.Array.clone(this.getData());

If it does, same means would have to be applied to other data setting
methods (at least setRowsAsMapArray() - are there others?).

Greetings,
Stefan

danovics wrote:
> Thank you _very_ much for your answer.
> It's good to know, that is not me or my code make the mistake.
> Although I didn't understand 100% what you wrote, but I'll try the method
> you suggested.
> Thanks again.
>  
>
> Stefan Volbers wrote:
>> Hi danovics,
>>
>> looking at table/model/filtered.js, I believe it's a bug in Filtered.
>> Whenever resetHiddenRows() is called, a shadow table data
>> (this.__fullArr) is retrieved; but this would be set correctly only if
>> you used setData() in your application, the setRows() method seems to
>> have been forgotten. Therefore the shadow data isn't updated, and when
>> it is recalled within resetHiddenRows(), you get outdated data.
>> So, if my guess is right, a workaround would be to use setData() in your
>> cellClick listener (haven't tried myself).
>>
>> Dan is the author of the filtered model, maybe he can comment on that?
>>
>> HTH,
>> greetings,
>> Stefan
>>
>>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
NO
It doesn't work with this method neither.
I tried the following:
On the cellClick I add a new row to the table, with the changed checkbox value.
Immediately after that I remove the old row (on which the click occured).
After this I call the resetHiddenRows() method, and the result is the same like before, the changed checkbox return to its init state.

oh my....
????

danovics wrote
Actually I'm trying the removeRows(), addRows() method-combination. It seems to be a little bit faster than change all the datas.
I'll write my experiences with this.

Greetings
Daniel
 
Stefan Volbers wrote
Inspired by your friendly answer, I further looked into this.

Can someone confirm if this patch for qx/ui/table/model/Filtered.js
resolves the mentioned problem (assuming qooxdoo-0.8.3-sdk)?

410a411,419
 >     },
 >
 >
 >     // overridden
 >     setRows : function(rowArr, startIndex, clearSorting)
 >     {
 >       this.Filters = [];
 >       this.base(arguments, rowArr, startIndex, clearSorting);
 >       this.__fullArr = qx.lang.Array.clone(this.getData());

If it does, same means would have to be applied to other data setting
methods (at least setRowsAsMapArray() - are there others?).

Greetings,
Stefan

danovics wrote:
> Thank you _very_ much for your answer.
> It's good to know, that is not me or my code make the mistake.
> Although I didn't understand 100% what you wrote, but I'll try the method
> you suggested.
> Thanks again.
>  
>
> Stefan Volbers wrote:
>> Hi danovics,
>>
>> looking at table/model/filtered.js, I believe it's a bug in Filtered.
>> Whenever resetHiddenRows() is called, a shadow table data
>> (this.__fullArr) is retrieved; but this would be set correctly only if
>> you used setData() in your application, the setRows() method seems to
>> have been forgotten. Therefore the shadow data isn't updated, and when
>> it is recalled within resetHiddenRows(), you get outdated data.
>> So, if my guess is right, a workaround would be to use setData() in your
>> cellClick listener (haven't tried myself).
>>
>> Dan is the author of the filtered model, maybe he can comment on that?
>>
>> HTH,
>> greetings,
>> Stefan
>>
>>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Stefan Volbers
Hi Daniel,

I'm not very surprised that this doesn't work, as the addRow() etc.
methods don't get overridden in Filtered.js.
The filtered model keeps an array of the complete (unfiltered) model
data; this is saved correctly only if you apply it with setData() (as
only this setting method is overridden in Filtered.js). Having the model
save the model data is essential for what you want to do.

I'd still like to know if my proposed patch would remedy the issue. So I
suggest you retain your original application class (using setRows()) and
create a custom model class which inherits from model.Filtered (say,
Filtered2; remember to call this.base(arguments) in the constructor).
Have it override setRows() with the three lines of code in my earlier
mail, and let your application use the new custom filtered model.

After a ./generate source your application should no longer forget the
data in question.

Shouldn't be too much hassle to test this, and if you succeed, we could
file a bug report to get this issue done.

Greetings,
Stefan

danovics wrote:

> NO
> It doesn't work with this method neither.
> I tried the following:
> On the cellClick I add a new row to the table, with the changed checkbox
> value.
> Immediately after that I remove the old row (on which the click occured).
> After this I call the resetHiddenRows() method, and the result is the same
> like before, the changed checkbox return to its init state.
>
> oh my....
> ????
>
>
> danovics wrote:
>> Actually I'm trying the removeRows(), addRows() method-combination. It
>> seems to be a little bit faster than change all the datas.
>> I'll write my experiences with this.
>>
>> Greetings
>> Daniel
>>  
>>
>> Stefan Volbers wrote:
>>> Inspired by your friendly answer, I further looked into this.
>>>
>>> Can someone confirm if this patch for qx/ui/table/model/Filtered.js
>>> resolves the mentioned problem (assuming qooxdoo-0.8.3-sdk)?
>>>
>>> 410a411,419
>>>  >     },
>>>  >
>>>  >
>>>  >     // overridden
>>>  >     setRows : function(rowArr, startIndex, clearSorting)
>>>  >     {
>>>  >       this.Filters = [];
>>>  >       this.base(arguments, rowArr, startIndex, clearSorting);
>>>  >       this.__fullArr = qx.lang.Array.clone(this.getData());
>>>
>>> If it does, same means would have to be applied to other data setting
>>> methods (at least setRowsAsMapArray() - are there others?).
>>>
>>> Greetings,
>>> Stefan
>>>
>>> danovics wrote:
>>>> Thank you _very_ much for your answer.
>>>> It's good to know, that is not me or my code make the mistake.
>>>> Although I didn't understand 100% what you wrote, but I'll try the
>>>> method
>>>> you suggested.
>>>> Thanks again.
>>>>  
>>>>
>>>> Stefan Volbers wrote:
>>>>> Hi danovics,
>>>>>
>>>>> looking at table/model/filtered.js, I believe it's a bug in Filtered.
>>>>> Whenever resetHiddenRows() is called, a shadow table data
>>>>> (this.__fullArr) is retrieved; but this would be set correctly only if
>>>>> you used setData() in your application, the setRows() method seems to
>>>>> have been forgotten. Therefore the shadow data isn't updated, and when
>>>>> it is recalled within resetHiddenRows(), you get outdated data.
>>>>> So, if my guess is right, a workaround would be to use setData() in
>>>>> your
>>>>> cellClick listener (haven't tried myself).
>>>>>
>>>>> Dan is the author of the filtered model, maybe he can comment on that?
>>>>>
>>>>> HTH,
>>>>> greetings,
>>>>> Stefan
>>>>>
>>>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> qooxdoo-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>>
>>>
>>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
A cannot say enough _thank you_.
I was a little bit afraid of your code, but i tried to understand it, and it seems to be working!!!
thankyouthankyouthankyou

(a very happy) Daniel

Stefan Volbers wrote
Hi Daniel,

I'm not very surprised that this doesn't work, as the addRow() etc.
methods don't get overridden in Filtered.js.
The filtered model keeps an array of the complete (unfiltered) model
data; this is saved correctly only if you apply it with setData() (as
only this setting method is overridden in Filtered.js). Having the model
save the model data is essential for what you want to do.

I'd still like to know if my proposed patch would remedy the issue. So I
suggest you retain your original application class (using setRows()) and
create a custom model class which inherits from model.Filtered (say,
Filtered2; remember to call this.base(arguments) in the constructor).
Have it override setRows() with the three lines of code in my earlier
mail, and let your application use the new custom filtered model.

After a ./generate source your application should no longer forget the
data in question.

Shouldn't be too much hassle to test this, and if you succeed, we could
file a bug report to get this issue done.

Greetings,
Stefan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Stefan Volbers
Glad I could help.

http://bugzilla.qooxdoo.org/show_bug.cgi?id=3100
lists the bug; maybe we can get some comments of the core devs there.

Greetings,
Stefan

danovics wrote:

> A cannot say enough _thank you_.
> I was a little bit afraid of your code, but i tried to understand it, and it
> seems to be working!!!
> thankyouthankyouthankyou
>
> (a very happy) Daniel
>
>
> Stefan Volbers wrote:
>> Hi Daniel,
>>
>> I'm not very surprised that this doesn't work, as the addRow() etc.
>> methods don't get overridden in Filtered.js.
>> The filtered model keeps an array of the complete (unfiltered) model
>> data; this is saved correctly only if you apply it with setData() (as
>> only this setting method is overridden in Filtered.js). Having the model
>> save the model data is essential for what you want to do.
>>
>> I'd still like to know if my proposed patch would remedy the issue. So I
>> suggest you retain your original application class (using setRows()) and
>> create a custom model class which inherits from model.Filtered (say,
>> Filtered2; remember to call this.base(arguments) in the constructor).
>> Have it override setRows() with the three lines of code in my earlier
>> mail, and let your application use the new custom filtered model.
>>
>> After a ./generate source your application should no longer forget the
>> data in question.
>>
>> Shouldn't be too much hassle to test this, and if you succeed, we could
>> file a bug report to get this issue done.
>>
>> Greetings,
>> Stefan


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
In reply to this post by Stefan Volbers
Hi Stefan

A new day a new issue.
So the situation for now:
I have a for row long table (filtered model) with two columns. For example:

 true, item1
 true, item2
 false, item3
 false, item4

And I have 3 buttons: Show all, Checked, Unchecked.
After init the table is in Sholl all state.
Thanks to your modification code when in Shaw all state I change the value of checkboxes everything just works fine.

But:
When I change a cb value in filtered view (when I see only table rows in which the first cell contains only unchecked or checked checkboxes) the mechanism go broke. Because after this change the tableModel will contains only the visible rows and forget the filtered-out ones.

Here is my code for the cellClick event, where I change the chekboxes value:
<code>
            table.addListener("cellClick", function(e) {
                if (e.getColumn() == 1) { // if clicked cell is in the first column change checkbox
                    var selectedRowIndex, selectedRowData
                    selectionModel.iterateSelection(function(index) {
                        selectedRowIndex = index;
                        selectedRowData = (tableModel.getRowData(index));
                    });
                    if (selectedRowData[1] !== null) { // if the cell contains checkbox
                        var newTableModel = [];
                        var newRowData = [[selectedRowData[0], !selectedRowData[1], selectedRowData[2]]];
                        tableModel.setRows(newRowData, selectedRowIndex);
                    }
                }
            });
</code>

I wonder if there is a possibility to manipulate tableModel in filtered state without data loss.

Greetings
Daniel

Stefan Volbers wrote
Hi Daniel,

I'm not very surprised that this doesn't work, as the addRow() etc.
methods don't get overridden in Filtered.js.
The filtered model keeps an array of the complete (unfiltered) model
data; this is saved correctly only if you apply it with setData() (as
only this setting method is overridden in Filtered.js). Having the model
save the model data is essential for what you want to do.

I'd still like to know if my proposed patch would remedy the issue. So I
suggest you retain your original application class (using setRows()) and
create a custom model class which inherits from model.Filtered (say,
Filtered2; remember to call this.base(arguments) in the constructor).
Have it override setRows() with the three lines of code in my earlier
mail, and let your application use the new custom filtered model.

After a ./generate source your application should no longer forget the
data in question.

Shouldn't be too much hassle to test this, and if you succeed, we could
file a bug report to get this issue done.

Greetings,
Stefan

qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Stefan Volbers
I still hope we get a comment from the author - maybe we're on the wrong
trail? You should know that I never used filtered model before...

Maybe later today I have time to look deeper into this.

Greetings,
Stefan

danovics wrote:

> Hi Stefan
>
> A new day a new issue.
> So the situation for now:
> I have a for row long table (filtered model) with two columns. For example:
>
>  true, item1
>  true, item2
>  false, item3
>  false, item4
>
> And I have 3 buttons: Show all, Checked, Unchecked.
> After init the table is in Sholl all state.
> Thanks to your modification code when in Shaw all state I change the value
> of checkboxes everything just works fine.
>
> But:
> When I change a cb value in filtered view (when I see only table rows in
> which the first cell contains only unchecked or checked checkboxes) the
> mechanism go broke. Because after this change the tableModel will contains
> only the visible rows and forget the filtered-out ones.
>
> Here is my code for the cellClick event, where I change the chekboxes value:
> <code>
>             table.addListener("cellClick", function(e) {
>                 if (e.getColumn() == 1) { // if clicked cell is in the first
> column change checkbox
>                     var selectedRowIndex, selectedRowData
>                     selectionModel.iterateSelection(function(index) {
>                         selectedRowIndex = index;
>                         selectedRowData = (tableModel.getRowData(index));
>                     });
>                     if (selectedRowData[1] !== null) { // if the cell
> contains checkbox
>                         var newTableModel = [];
>                         var newRowData = [[selectedRowData[0],
> !selectedRowData[1], selectedRowData[2]]];
>                         tableModel.setRows(newRowData, selectedRowIndex);
>                     }
>                 }
>             });
> </code>
>
> I wonder if there is a possibility to manipulate tableModel in filtered
> state without data loss.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Dave Baggett
In reply to this post by danovics
You should strongly consider migrating to the Smart table model contrib. I wrote it exactly because the problems with Filtered were not easily fixable with simple workarounds and patches to the code. That said, the Smart table model is derived from Filtered in concept, and should be a drop-in replacement for Simple. You will have to adapt your use of filtering to the different API that Smart offers. The Smart model code is reasonably well documented, and Fritz Zaucker and I can help you figure out how to use it if need be.

I can't speak for the QooxDoo team, but my guess is that Smart will ultimately replace Filtered as there has been almost no activity on Filtered bug fixes in the past long while... and Smart addresses all the Filtered issues currently logged in the QooxDoo bugzilla.

Probably not what you wanted to hear, exactly, but that's my advice...

Dave

danovics wrote
Hi Stefan

A new day a new issue.
So the situation for now:
I have a for row long table (filtered model) with two columns. For example:

 true, item1
 true, item2
 false, item3
 false, item4

And I have 3 buttons: Show all, Checked, Unchecked.
After init the table is in Sholl all state.
Thanks to your modification code when in Shaw all state I change the value of checkboxes everything just works fine.

But:
When I change a cb value in filtered view (when I see only table rows in which the first cell contains only unchecked or checked checkboxes) the mechanism go broke. Because after this change the tableModel will contains only the visible rows and forget the filtered-out ones.

Here is my code for the cellClick event, where I change the chekboxes value:
<code>
            table.addListener("cellClick", function(e) {
                if (e.getColumn() == 1) { // if clicked cell is in the first column change checkbox
                    var selectedRowIndex, selectedRowData
                    selectionModel.iterateSelection(function(index) {
                        selectedRowIndex = index;
                        selectedRowData = (tableModel.getRowData(index));
                    });
                    if (selectedRowData[1] !== null) { // if the cell contains checkbox
                        var newTableModel = [];
                        var newRowData = [[selectedRowData[0], !selectedRowData[1], selectedRowData[2]]];
                        tableModel.setRows(newRowData, selectedRowIndex);
                    }
                }
            });
</code>

I wonder if there is a possibility to manipulate tableModel in filtered state without data loss.

Greetings
Daniel

Stefan Volbers wrote
Hi Daniel,

I'm not very surprised that this doesn't work, as the addRow() etc.
methods don't get overridden in Filtered.js.
The filtered model keeps an array of the complete (unfiltered) model
data; this is saved correctly only if you apply it with setData() (as
only this setting method is overridden in Filtered.js). Having the model
save the model data is essential for what you want to do.

I'd still like to know if my proposed patch would remedy the issue. So I
suggest you retain your original application class (using setRows()) and
create a custom model class which inherits from model.Filtered (say,
Filtered2; remember to call this.base(arguments) in the constructor).
Have it override setRows() with the three lines of code in my earlier
mail, and let your application use the new custom filtered model.

After a ./generate source your application should no longer forget the
data in question.

Shouldn't be too much hassle to test this, and if you succeed, we could
file a bug report to get this issue done.

Greetings,
Stefan

qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
Hi Dave

Thanks for the answer.
I would be glad to change my table model to whatever, if it suits my needs.
I looked up in the current qx api, but I didn't find smart table model. There only exist Filtered, Remote and Simple.
Where should I look for the mentioned Smart table model?

Best regarsd
Daniel

Dave Baggett wrote
You should strongly consider migrating to the Smart table model contrib. I wrote it exactly because the problems with Filtered were not easily fixable with simple workarounds and patches to the code. That said, the Smart table model is derived from Filtered in concept, and should be a drop-in replacement for Simple. You will have to adapt your use of filtering to the different API that Smart offers. The Smart model code is reasonably well documented, and Fritz Zaucker and I can help you figure out how to use it if need be.

I can't speak for the QooxDoo team, but my guess is that Smart will ultimately replace Filtered as there has been almost no activity on Filtered bug fixes in the past long while... and Smart addresses all the Filtered issues currently logged in the QooxDoo bugzilla.

Probably not what you wanted to hear, exactly, but that's my advice...

Dave
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Dave Baggett
Check out the QooxDoo Contrib page:

  http://qooxdoo.org/contrib

If you look in Available Contributions, you'll see SmartTableModel. You can browse the code from there and check out all the docs (read the comments; that's what the docs are generated from in QooxDoo).

BTW, I'm not sure how to view a nice docview version like you get in the API viewer. I think that was discussed for contribs on the forum recently, but I don't remember the conclusion.

Dave

danovics wrote
Hi Dave

Thanks for the answer.
I would be glad to change my table model to whatever, if it suits my needs.
I looked up in the current qx api, but I didn't find smart table model. There only exist Filtered, Remote and Simple.
Where should I look for the mentioned Smart table model?

Best regarsd
Daniel

Dave Baggett wrote
You should strongly consider migrating to the Smart table model contrib. I wrote it exactly because the problems with Filtered were not easily fixable with simple workarounds and patches to the code. That said, the Smart table model is derived from Filtered in concept, and should be a drop-in replacement for Simple. You will have to adapt your use of filtering to the different API that Smart offers. The Smart model code is reasonably well documented, and Fritz Zaucker and I can help you figure out how to use it if need be.

I can't speak for the QooxDoo team, but my guess is that Smart will ultimately replace Filtered as there has been almost no activity on Filtered bug fixes in the past long while... and Smart addresses all the Filtered issues currently logged in the QooxDoo bugzilla.

Probably not what you wanted to hear, exactly, but that's my advice...

Dave
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

danovics
Thank you very much.
I found the contrib library and your code(s) in it.
Unfurtunatelly I didn't dig very deep in qx, so i'll need time to understand how to implement new things from contrib.
But it is my problem, thanks for help anyway.
Daniel
Dave Baggett wrote
Check out the QooxDoo Contrib page:

  http://qooxdoo.org/contrib

If you look in Available Contributions, you'll see SmartTableModel. You can browse the code from there and check out all the docs (read the comments; that's what the docs are generated from in QooxDoo).

BTW, I'm not sure how to view a nice docview version like you get in the API viewer. I think that was discussed for contribs on the forum recently, but I don't remember the conclusion.

Dave
Reply | Threaded
Open this post in threaded view
|

Re: filtered table with checkboxes - problem

Dave Baggett
Yes, that is still a bit confusing. If you search the forums, you'll find various posts on how to use contribs. Good luck — let us know if you need help.

Dave

<quote author="danovics">
Thank you very much.
I found the contrib library and your code(s) in it.
Unfurtunatelly I didn't dig very deep in qx, so i'll need time to understand how to implement new things from contrib.
But it is my problem, thanks for help anyway.
Daniel