1. 程式人生 > >easyui增刪改查前段代碼

easyui增刪改查前段代碼

creat clear UNC 時間 fit ber message text else

<script>
    var url;
    //添加用戶窗體
    function newUser()
    {
        $(#dlg).dialog(open).dialog(setTitle, 學生信息添加);
        $(#fm).form(clear);
        url = /Students/Add;
    }
    //編輯
    function editUser()
    {
        var row = $(#dg).datagrid(getSelected
); if (row) { $(#dlg).dialog(open).dialog(setTitle, 修改學生信息); $(#fm).form(load, row); url = /Students/Edit/ + row.StuId; } } //提交方法 function saveUser() { $(#fm).form(submit, { url: url, onSubmit: function () {
return $(this).form(validate); }, success: function (data) { if (data.Result==false) { $.messager.show({ title: Error, msg: data.Message }); } else
{ $(#dlg).dialog(close); // close the dialog $(#dg).datagrid(reload); // reload the user data } } }); } function InitGrid() { $("#dg").datagrid({ url: /Students/StudentRead, title: 學生列表, toolbar: #toolbar, rownumbers: true, fitcolumns: true, singleselect: true }); } </script> <table id="dg" title="My Users" class="easyui-datagrid" style="width:550px;height:250px" url="/Students/StudentRead" toolbar="#toolbar" rownumbers="true" fitcolumns="true" singleselect="true"> <thead> <tr> <th field="StuName" width="50">學生姓名</th> <th field="Age" width="50">年齡</th> <th field="Sex" width="50">性別</th> <th field="CreateTime" width="50">創建時間</th> </tr> </thead> </table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="newUser()">New User</a> <a href="#" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editUser()">Edit User</a> <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a> </div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px" closed="true" buttons="#dlg-buttons"> <div class="ftitle">學生信息</div> <form id="fm" method="post"> <div class="fitem"> <label>StuName:</label> <input name="StuName" class="easyui-textbox"> </div> <div class="fitem"> <label>Age:</label> <input name="Age" class="easyui-textbox"> </div> <input type="hidden" name="StuId"/> </form> </div> <div id="dlg-buttons"> <a href="#" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveUser()">Save</a> <a href="#" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$(‘#dlg‘).dialog(‘close‘)">Cancel</a> </div>

easyui增刪改查前段代碼