跳至内容

欢迎!

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.

此问题已终结
作为版主,您可以批准或拒绝该答案。
接受 拒绝
104 查看

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


形象
丢弃

您的回复

请大家尽量给个实质性的回答。如果您想回答这个问题或发表评论,只需 使用评论工具。请记住,您可以随时修改您的答案。 - 不用重复回答同样的问题。另外,请不要忘记投票 - 它确实有助于选择最好的问题和答案!

相关帖文 回复 查看 活动
0
2月 25
86
0
1月 25
54
0
1月 25
55
0
1月 25
78
0
3月 25
98