Okay
  Public Ticket #2891760
Order into select boxes
Closed

Comments

  • ANDRE PËDELUCQ started the conversation

    Hi,

    Great plugin.

    First, I create a table A to prepare a drop-down menu, with a sort order on a field.
    Then, I create a table B in which I put a field that will be edited by a single-choice drop-down menu.
    The order is not respected. Why ?

    Thanks

  • [deleted] replied

    Hi Andre

    Thank you for reaching out to us.

    Can you please share some screenshots of the issue or a link to the page we we can see this so we can get a better understanding? 

    How were these tables created?

  • ANDRE PËDELUCQ replied

    HI Blaženka, 

    The settings for the 2 tables :

    table B : Data source 
    SELECT t.`id`,
           t.`user_id`,
           t.`nom`,
           t.`prenom`,
           t.`id_promo`,
           u.`user_login`,
           t.`email`,
           t.`oublier`,
           t.`dcd`,
           t.`a_jour`,
           t.`no_carte`,
           t.`no_1`,
           t.`no_2`,
           t.`tel1`,
           t.`tel2`,
           t.`poster`,
           t.`adr1`,
           t.`adr2`,
           t.`code_postal`,
           t.`localite`,
           t.`pays`
    FROM wp02__tiers t
    LEFT JOIN wp02_users u ON t.user_id=u.ID
    WHERE `id_promo`>0

    Settings id_promo (INTEGER UNSIGNED into MySql table)
    - Data :
          - string
          - Use values from another wpDataTable (foreign key)
          - Config relation : see image for table B
    - Edit :
          - Single-value selectbox
          - Cannot be empty : ON

    table B : Data source
    SELECT `promo_id`,  `promotion` FROM wp02__promo WHERE `all_dead`=0

    Table Settings : Sort allowed
    Sort Field settings :
    - promo_id : none
    - promotion : 
          - Allow sorting for this column ON
          - Sort table by this column on load : ON

    What do you think ?

    Regards, André



  • [deleted] replied

    Hi Andre

    If your MySQL-query based wpDataTable doesn’t work correctly with server-side processing, probably this is happening because wpDataTables server has problems with parsing of the query and building new queries dynamically (rarely happens, but does sometimes). To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    If you still have the same issue please provide me with a temporary admin access to the website so I can have a closer look. 

    Please note some this when working with the server-side processing feature:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also, server-side processing feature adds this part of statement automatically when users trigger the sorting on the front-end, and having it in initial statement may cause the table to crash.

  • ANDRE PËDELUCQ replied

    Thanks Blaženka,

    I knox the use of the views, procedures, functions, triggers ... with MySQL. I had already tried.

    I created a view putting the indexed field first in DESC order:
    CREATE VIEW glyc__promos_vivantes AS SELECT `promotion`, `promo_id` FROM glyc__promo WHERE `all_dead`=0 ORDER BY `promotion` DESC;

    Then, I created a temporary DD table on the view:
    SELECT * FROM glyc__promos_vivantes
    Result OK

    I updated the promo_id field with the DD table for origin: always the same result = no descending order.
    I do not insist.


    On the off chance that I set DEBUG = ON and got a lot of the following errors:
    PHP Notice:  Undefined offset: 2 in /.../plugins/wpdatatables/source/class.wpdatatable.php on line 1831.

    Is it a track?

    Regards, André

  • [deleted] replied

    Hi André

    Honestly, I believe our developers will be able to assist you more with this matter, so I forwarded this to them. We will get back to you with more information.

    Thank you for your time and patience.

    There is nothing on that line in the current version. Which version do you use? To get the custom order to work, you must turn off sorting for the entire table in order to be applied, because ORDER BY is added dynamically.