• fastadmin列表,关联筛选查询


    fastadmin文章表关联分类表,分类筛选默认按分类名模糊查询,项目需求是下拉选择分类,根据分类id直接筛选。最终效果如下图。

    1. var table = $("#table");
    2. //在普通搜索渲染后
    3. table.on('post-common-search.bs.table', function (event, table) {
    4. var form = $("form", table.$commonsearch);
    5. $("input[name='cate_id']", form).addClass("selectpage").data("source", "htcms/cate/get_cate_list/model/1").data("primaryKey", "id").data("field", "cate_name").data("orderBy", "id desc");
    6. Form.events.cxselect(form);
    7. Form.events.selectpage(form);
    8. });
    9. //列表中添加如下代码
    10. //直接响应搜索
    11. {field: 'cate_id', title: __('Cate.cate_name'), formatter: Table.api.formatter.search,visible:false},

    整个js文件(查看添加位置)

    1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    2. var Controller = {
    3. index: function () {
    4. // 初始化表格参数配置
    5. Table.api.init({
    6. extend: {
    7. index_url: 'htcms/article/index' + location.search,
    8. add_url: 'htcms/article/add',
    9. edit_url: 'htcms/article/edit',
    10. del_url: 'htcms/article/del',
    11. multi_url: 'htcms/article/multi',
    12. import_url: 'htcms/article/import',
    13. table: 'htcms_article',
    14. }
    15. });
    16. var table = $("#table");
    17. //在普通搜索渲染后
    18. table.on('post-common-search.bs.table', function (event, table) {
    19. var form = $("form", table.$commonsearch);
    20. $("input[name='cate_id']", form).addClass("selectpage").data("source", "htcms/cate/get_cate_list/model/1").data("primaryKey", "id").data("field", "cate_name").data("orderBy", "id desc");
    21. Form.events.cxselect(form);
    22. Form.events.selectpage(form);
    23. });
    24. // 初始化表格
    25. table.bootstrapTable({
    26. url: $.fn.bootstrapTable.defaults.extend.index_url,
    27. pk: 'id',
    28. sortName: 'id',
    29. fixedColumns: true,
    30. fixedRightNumber: 1,
    31. columns: [
    32. [
    33. {checkbox: true},
    34. {field: 'id', title: __('Id'),operate: false},
    35. {field: 'title', title: __('Title'), operate: 'LIKE'},
    36. // {field: 'cate_id', title: __('Cate_id')},
    37. //直接响应搜索
    38. {field: 'cate_id', title: __('Cate.cate_name'), formatter: Table.api.formatter.search,visible:false},
    39. {field: 'cate.cate_name', title: __('Cate.cate_name'), operate: false},
    40. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
    41. {field: 'hits', title: __('Hits'),operate: false},
    42. {field: 'sort', title: __('Sort'),operate: false},
    43. {field: 'language_list', title: __('Language_list'), searchList: {"1":__('Language_list 1'),"2":__('Language_list 2'),"3":__('Language_list 3'),"4":__('Language_list 4'),"5":__('Language_list 5')}, formatter: Table.api.formatter.normal},
    44. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
    45. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
    46. {field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
    47. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
    48. ]
    49. ]
    50. });
    51. // 为表格绑定事件
    52. Table.api.bindevent(table);
    53. },
    54. add: function () {
    55. Controller.api.bindevent();
    56. },
    57. edit: function () {
    58. Controller.api.bindevent();
    59. },
    60. api: {
    61. bindevent: function () {
    62. Form.api.bindevent($("form[role=form]"));
    63. }
    64. }
    65. };
    66. return Controller;
    67. });

  • 相关阅读:
    01-Docker部署MongoDB
    12.7.1 实验7:实施路由器密码恢复
    LTE MAC 层1
    Spring 编程常见问题之三(专栏学习笔记)
    Redis 5 种基本数据结构(String、List、Hash、Set、Sorted Set)详解 | JavaGuide
    [附源码]计算机毕业设计JAVA龙虎时代健身房管理系统
    【C++】不能两次杀死同一条鱼 - 浅述shared_ptr智能指针的使用方法
    【Pandas总结】第四节 Pandas 缺失值处理(通过实例进行演示)
    Hadoop对集群的一些操作的命令介绍
    emqx创建规则引擎写入tDengine
  • 原文地址:https://blog.csdn.net/qq_40088333/article/details/132717597