FixedColumns - Freeze arbitrary columns

FixedColumns - Freeze arbitrary columns

ArtjomArtjom Posts: 48Questions: 0Answers: 0
edited February 2013 in General
As far as I understand, for the time being the fixedColumns plugin only allows to select a continuous interval of columns on the left and/or right of the table. Is it possible to freeze an arbitrary set of columns?

For instance, we have a table with the following set of columns { Col1, Col2, Col3, Col4, Col5 } and we want to freeze Col2 and Col5 so that the final table looks like this { fCol2, fCol5, Col1, Col3, Col4 }.

Is such a configuration possible and is there a workaround for this if it's not.

Thanks in advance.
Artjom

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    > Is it possible to freeze an arbitrary set of columns?

    No - this is not possible. You are looking for a floating column in the middle of the table? What is the use case?

    If you want columns 2 and 5 at the start of the table (not eh left), why not reorder your table so that columns 2 and 5 are in that position?

    Allan
  • ArtjomArtjom Posts: 48Questions: 0Answers: 0
    edited February 2013
    Thanks for the reply and I will try to explain myself better. I mean that I need to freeze certain columns in the table, for instance Col2 and Col5 (i.e I can specify the columns to freeze in a script as an option). These columns would appear on the left of the table (current behavior) and the rest of the table (not frozen columns) would be rearranged and shown after the ones that were frozen.

    It is exactly as I have described in the previous post (let's assume that columns to freeze are specified in the script).

    -------existing table------------columns 2 and 5------table with columns 2 and 5 frozen-------

    { Col1, Col2, Col3, Col4, Col5 } ----after freeze---> { fCol2, fCol5, Col1, Col3, Col4 }

    Right now it seems that it works like this. We set, for instance,

    "iLeftColumns": 2

    and then two columns on the left would be frozen, that is,

    { Col1, Col2, Col3, Col4, Col5 } ----after freeze---> { fCol1, fCol2, Col3, Col4, Col5 }

    Actually what I describe is already available in another framework jEasy UI that is also based on jQuery. However, I was unable to make it work with the existing table. Perhaps, you can take a look and see the use case that I describe.

    http://www.jeasyui.com/tutorial/datagrid/datagrid5.php

    Best regards,
    Artjom
  • ArtjomArtjom Posts: 48Questions: 0Answers: 0
    bump
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Why not just move column 2 and 5 to the start of the table - i.e. reorder your table? You could possibly use ColReorder to programmatically do that, but I don't quite understand why you can't just reorder the table columns and then use FixedColumns as is?

    Allan
  • ArtjomArtjom Posts: 48Questions: 0Answers: 0
    edited February 2013
    Ok, I will look into it. The combination of plugins you've mentioned seems to be a good candidate for a solution. As I have discovered DataTables recently I have a vague overview of the options available. I wanted someone to point me in the right direction.

    :) Thanks allan.
  • ArtjomArtjom Posts: 48Questions: 0Answers: 0
    Allan, could you provide an example of how to do it programmatically.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Are you not able to change the order of the HTML table? That really would be the easiest option.
  • ArtjomArtjom Posts: 48Questions: 0Answers: 0
    edited February 2013
    I'll describe my use case :).

    The tables are part of the XML documents generated at runtime by the backend. At the next step these files would be transformed with the corresponding XSLT files into HTML pages and rendered by the browser. In the transformation phase the set of frozen columns for the tables have to be provided, that is they have to be specified in XSLT files used for transformation. Depending on the service used there could be different set of columns frozen (this means it has to be configurable through xslt by the portal maintainers).

    That's why I can't simply change the order by hand :).

    You've proposed to use ColReorder plugin in combination with FixedColumns to programmatically rearrange the order of the tables before applying a column freeze. I looked through the examples provided but wasn't able to determine how to use these two plugins together for such a scenario.

    Any help would be appreciated.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Ah I see. Thanks for the explanation.

    So you'd use the aiOrder option of ColReorder to do the initial reorder during the initialisation of the table: http://www.datatables.net/extras/colreorder/options#aiOrder . Then add FixedColumns as normal.

    Allan
This discussion has been closed.