Order By in edittype = select does not work

QuestionsOrder By in edittype = select does not work
Patricia Lawson asked 7 years ago

Hello,
I have a column with edittype = select
The SQL for the select uses an Order By stmt which brings back the data in the incorrect order. The SQL resolves correctly in phpmyadmin.

code:
$col["edittype"] = "select";
$str = $detailGrid->get_dropdown_values("(SELECT ListID as k, name as v FROM iteminventory WHERE name = 'Special Instructions' LIMIT 1)
UNION
(SELECT i.ListID as k, CONCAT_WS(' ',name, IF( `QuantityOnHand`>=(`QuantityOnSalesOrder`+1),'','Not in Stock' ) ) as v
FROM pal_pd_products p
JOIN (SELECT name, ListID, QuantityOnHand, QuantityOnSalesOrder FROM iteminventory) i
ON i.name = CONCAT(p.model,'-',p.color_code)
WHERE p.status IN ('A','D','PR','RI','S')
ORDER BY p.model, p.color_code
LIMIT 2000)");
$col["formatter"] = "select";
$col["editoptions"] = array("value" => $str);

(p.model and p.color_code are varchars)

Result in phpmyadmin:
604-35 Not in Stock ** Correct order
604-76
604-95
6043-1

Result in Select dropdown:
604-76
604-95
6043-1
6047-3

604-35 Not in Stock ** This should show before 604-76

Everything else works just fine. (If I remove the UNION it makes no difference)
Thanks in advance

1 Answers
Abu Ghufran answered 7 years ago

Hello,

This case is little difficult to regenerate. It is working on basic example: http://prntscr.com/fxrj64
$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients ORDER BY name desc");

You can email me database sql dump to test-run this case. ([email protected])

Your Answer

4 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?