Saravananscope / dragtable

Automatically exported from code.google.com/p/dragtable
0 stars 0 forks source link

Dragtable forgets column ordering between page loads #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
To reproduce:
1. Load a page that uses dragtable
2. Rearrange some columns
3. Click a link
4. Click the back button

The columns have reverted to their original ordering. This could be fixed
by storing a cookie that keeps track of column ordering. This problem also
affects sorttable.

Original issue reported on code.google.com by danvdk on 26 Jun 2008 at 7:46

GoogleCodeExporter commented 8 years ago
Hi!
Very nice!

Original comment by pavel.vl...@gmail.com on 29 Jun 2008 at 12:08

GoogleCodeExporter commented 8 years ago
yes I faced this problem too. I am using this code in JSF. This code is bloody 
useful.
Thank you thank you thank you so much! However like danvdk has said, the order 
is not
retained between pages.

Original comment by saspid...@gmail.com on 5 Sep 2008 at 6:01

GoogleCodeExporter commented 8 years ago
hi, i'm new to both javascript and cookies, is there any chance that anyone 
could 
show me some simple code to implement cookies to keep track of the column 
ordering? 
Thank you..

Original comment by superbab...@gmail.com on 22 Oct 2008 at 12:05

GoogleCodeExporter commented 8 years ago
A question for users of dragtable: would you prefer column ordering be saved in 
a
cookie by default?

The main options I'm considering are:
1. Make all draggable tables remember their ordering by default. To turn this 
off,
specify class="no-remember-ordering".
2. Make all draggable tables forget their ordering by default (like they do 
now). To
get the remembering, add class="remember-ordering".

I'm leaning towards #1.

Original comment by danvdk on 30 Jun 2009 at 9:42

GoogleCodeExporter commented 8 years ago
I've added this functionality in r18, r19 and r20. Here's how it works:

If you give your table an id (e.g. <table class=draggable id=mytable>) then 
dragtable
will store column moves in a cookie called "dragtable-mytable" for your page.

The cookie is a series of drags. For instance, a value of "1/3,2/1" means that 
the
user dragged column #1 on top of column #3, then dragged column #2 on top of 
column #1.

When dragtable.makeDraggable is called on a table (either explicitly or on page
load), dragtable checks for a cookie and replays all the drags. This isn't the 
most
efficient way to reorder the table, but it is transparently correct and I 
haven't run
into any performance problems with it.

To disable the use of cookies for a table, you can add class="forget-ordering" 
to it,
e.g. <table id=foo class="draggable forget-ordering">.

Original comment by danvdk on 30 Jun 2009 at 11:20

GoogleCodeExporter commented 8 years ago
Hi Dan,

I have been trying to implement dragging and sorting on a dynamic table in my 
classic 
ASP application. Though drag and sort works fine, the column ordering is not 
being 
preserved, even after providing the table with an id, of course.

The table columns are dynamically structured based on which columns user has 
opted to 
be displayed on the screen.

Also, I'm using the same machine to browse the application as client on which 
it is 
hosted. I hope that shouldn't throw things out of place, or should it?

I do have the latest release of dragtable.js. Hope you could clear my 
understanding a 
bit here. No heavies :)

Cheers,
Kamal 

Original comment by kamalana...@gmail.com on 11 Nov 2009 at 2:33

GoogleCodeExporter commented 8 years ago
Also, to mention that the cookie is being created with relevant info. It does 
contain 
the .asp page name and the old/new column location info with bits of other info.

However, it seems that it isn't reading and applying the correct order to the 
columns. 
Maybe because of ASP dynamic table?

Original comment by kamalana...@gmail.com on 11 Nov 2009 at 3:57

GoogleCodeExporter commented 8 years ago
Sorry for multiple updates, but to let you know that the column order IS 
remembered 
in FF. I'm using IE6 and have tested with IE7 as well, but no go.

The IE cookie looks like this:

dragtable-tableID
2/0
localhost/<address>.asp
1088
3830941440
30114235
1809960240
30040810
*

Is this normal? FF cookie displays the path and name of the cookie only. Any 
pointers 
to resolve this would be appreciated.

Original comment by kamalana...@gmail.com on 11 Nov 2009 at 4:33

GoogleCodeExporter commented 8 years ago
Ok. I have I think figured out what's going wrong. My application already 
creates a 
cookie, testcookie. So when this code tries to create another cookie "dragtable-
tableID" using document.cookie, it appends the new cookie to the existing 
cookie 
string, seperated by a ";" of-course. So in the loop where we split the string 
by a 
";", it reads the earlier cookie "testcookie" and hence does not replay the 
column 
ordering. This happens in IE, not in FF. I'll try and sort this out and let you 
know 
where I reach. Hopefully, some place good :-)

Original comment by kamalana...@gmail.com on 11 Nov 2009 at 11:04

GoogleCodeExporter commented 8 years ago
OK, here it is. 

The line of code that you entered in r20: 

var path = document.location.pathname;
    document.cookie = name+"="+value+expires+"; path="+escape(path)

won't work if your page names has an "_". My asp page had an "_" in it and 
document.cookie did not work in IE, though it did in FF.

So, reverting back to r19 resolved the issue.

Original comment by kamalana...@gmail.com on 12 Nov 2009 at 4:09

GoogleCodeExporter commented 8 years ago
I am also finding that the dragtable cookie is not being set/read correctly in 
IE8, 
though it works in Firefox and Opera. My application uses other cookies on this 
web 
page and the web page is served via https. Any ideas?

Original comment by lqu...@googlemail.com on 18 May 2010 at 5:18