1. 程式人生 > 其它 >Layui實現表格過載

Layui實現表格過載

在使用layui中的搜尋功能時需要用到表格過載,表格過載的格式如下:

table.reload(ID, options, deep)

其中引數 ID 要過載的表格的 id

引數 options 即為各項基礎引數

引數 deep:是否採用深度過載(即引數深度克隆,也就是過載時始終攜帶初始時及上一次過載時的引數),預設 false

列表展示時直接搜尋所有資料渲染在頁面中,實現搜尋功能時在後端需要使用動態SQL語句,將搜尋條件寫在SQL搜尋中,搜尋條件為空時顯示所有資料

表格過載

            table.reload('currentTableId', {
                url: '/api/training/page'
                ,where: {
                    train_date:train_date
                } //設定非同步資料介面的額外引數
            });

SQL語句

<select id="select" resultType="com.manager.entity.Training">
        select * from y_training
        <where>
            <if test="train_date!=null">
                train_date=#{train_date}
            </if>
        </where>
    </select>