B-JUI 實踐 之 帶搜索與編輯的Datagrid


使用B-JUI 1.31版本

DataGrid 頁直接上代碼:

<div class="bjui-pageHeader" style="background-color: #fefefe; border-bottom: none;">
    <form data-toggle="ajaxsearch" id="findglobalform" data-options="{searchDatagrid:$.CurrentNavtab.find('#datagrid-globals')}">
        <fieldset>
            <legend style="font-weight:normal;">搜索:</legend>
            <div style="margin:0; padding:1px 5px 5px;">
                <span>姓名全拼:</span>
                <input name="pinyin" size="10">&nbsp;
                <span>性別:</span>
                <select name="sex">
                    <option value="">全部</option>
                    <option value="M"></option>
                    <option value="F"></option>
                </select>&nbsp;
                <span>生日:</span>
                 <input name="birth" type="text" value="" data-toggle="datepicker" placeholder="點擊選擇日期" data-pattern="yyyy-MM-dd" readonly="true">&nbsp;
                <span>身份證:</span>
                <input name="idcard" size="20">

                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">查詢!</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered" id="datagrid-globals" data-toggle="datagrid" data-options="{
        loadType:'GET',
        filterThead:false,
        columnFilter:false,
        columnMenu:false,
        showCheckboxcol:false,
        height: '98%',
        width:'100%',
        gridTitle : '全局ID列表',
        showToolbar: true,
        toolbarCustom: globallistbar,
        dataUrl: 'service/global/list',        
        dataType: 'json',             
        editMode: {dialog:{width:'500',height:300,title:'編輯人員信息',mask:true,fresh:true,beforeClose:'closeeditglobal'}},
        editUrl: 'html/pixconf/editglobal.html',
        delUrl:'service/global/delete',
        delPK:'globalid',       
        paging: {pageSize:2,selectPageSize:'15,30'},        
        linenumberAll: true
        
        
    }">
        <thead>
            <tr>
                <th data-options="{name:'globalid',align:'center',width:20,quicksort:false}">ID</th>
                <th data-options="{name:'name',align:'center',width:70,quicksort:false}">姓名</th>
                <th data-options="{name:'sex',render:'renderSexType',align:'center',width:40}">性別</th>
                <th data-options="{name:'birth',align:'center',width:120,quicksort:false}">生日</th>
                <th data-options="{name:'mobile',align:'center',width:140,quicksort:false}">手機號</th>
                <th data-options="{name:'idcard',align:'center',width:170,quicksort:false}">身份證</th>
                <th data-options="{name:'medcard',align:'center',width:170,quicksort:false}">社保號</th>
                <th data-options="{render:'global_operation',align:'center',quicksort:false}">操作</th>
            </tr>
        </thead>
    </table>
</div>
<script type="text/javascript">
function closeeditglobal() {

    $.CurrentNavtab.find('#datagrid-globals').datagrid('refresh');
    return true;
}

function renderSexType(value) {
    return (value == 'F') ? '' : '';
}

function newGlobal() {
    BJUI.dialog({
        id: 'newglobaldlg',
        url: 'html/pixconf/addglobal.html',
        title: '新增人員',
        mask: true,
        height: 400,
        width: 500,
    });
}

function globallistbar() {
    return '<button type="button" class="btn-blue" data-icon="plus" onclick="newGlobal()">新增</button>';
}
// 操作列
function global_operation() {
    var html = '<button type="button" class="btn-green" data-toggle="edit.datagrid.tr">編輯</button>' + '<button type="button" class="btn-red" data-toggle="del.datagrid.tr">刪除</button>'

    return html
}
</script>

 

效果如圖:

 

 

分頁

后台必須接收的參數為:pageCurrent,pageSize

后台返回的數據格式為:{"totalRow":1,"list":[{"globalid":3,"address":"","birth":"2017-01-08","idcard":"130828198711120030","medcard":"1122334455667788","mobile":"13399998888","name":"王五","sex":"F","pinyin":"wangwu"}],"status":0}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM