Skip to Content

Welcome!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

This question has been flagged
As a moderator, you can either validate or reject this answer.
Accept Reject
53 Views

If u want sort it by alphabet, but the data in database is id. So when u click the sort button. it will sort by id desc or asc. 


How adjust it able getting the name instead of id?


First, u can go to default.php

As you can see, the th is using a.id. U can modified it to name, which is the name you retrieve from.


But before that, you should inner join the table first if the component haven't join the table yet

Go to model

Example file location


Inner join the table


This is just an example

Logic: 

inner join the dt_agent table to get the user id based on agent id

inner join the users table to get user name based on user id


After that, u need add the field in the function construct that u want to join like (c.ur_field_name)

why c.?

Becasue u join the table as c

Example:


Finally, after u inner join the table, then u can add the field_name into the th (which is field storing the name, not the id)


Now go to ur component, and try to click sort button, it already able to sort by name's asc or desc


Keypiont:

the sort by function is based on the column's th field, so u can direct adjust the field based on ur requirements


Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Related Posts Replies Views Activity
0
Feb 25
43
0
Jan 25
42
0
Jan 25
38
0
Jan 25
56
0
Mar 25
30