zoukankan      html  css  js  c++  java
  • easyui增删改查前段代码

    <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="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="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>
  • 相关阅读:
    table表格
    常见页面布局方式(三种框架集)
    学习标签属性3
    学习标签属性2
    学习标签属性1
    Purity in My Programming: Functions in Go
    cron一有趣处
    go函数作为一等民
    LRU算法
    go中的一个网络重连复用
  • 原文地址:https://www.cnblogs.com/tianranhui/p/10663010.html
Copyright © 2011-2022 走看看