I want to sort datatable by month name and the month names are in french how would I do that . I have searched alot but didn't get any result. Any will be of great use . Thank you
2条回答 默认 最新
- drmet46444 2015-07-27 11:28关注
You have searched? I dont think so
ORDER BY FIELD(MONTH,'January','February','March',...) SELECT leave_balance.balance, MonthName(leave_balance.date_added) AS month FROM leave_balance WHERE leave_balance.staff_id_staff = $iid GROUP BY month, leave_balance.leave_type_id_leave_type HAVING leave_balance.leave_type_id_leave_type = $leaveBalTypID ORDER BY FIELD(MONTH,'January','February','March',...,'December');
Duplicate from: MySql - order by monthname
First google result
Datatables, my bad, and still, first result ;)
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; jQuery.fn.dataTableExt.oSort['month-name-asc'] = function (x, y) { var xPos, yPos; jQuery.each(monthNames, function (k, v) { if (x == v) xPos = k; if (y == v) yPos = k }); return ((xPos < yPos) ? -1 : ((xPos > yPos) ? 1 : 0)); }; jQuery.fn.dataTableExt.oSort['month-name-desc'] = function (x, y) { var xPos, yPos; jQuery.each(monthNames, function (k, v) { if (x == v) xPos = k if (y == v) yPos = k }); return ((xPos > yPos) ? -1 : ((xPos < yPos) ? 1 : 0)); };
http://drmsite.blogspot.com/2013/08/datatables-custom-sort-by-month-name.html
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号