easyUI 中datatGrid操作

來源:互聯網
上載者:User

拼接的資料顯示

不同的格式顯示

引入的js和css    <link rel="stylesheet"type="text/css" href="themes/default/easyui.css" />    <link rel="stylesheet"type="text/css" href="CSS/icon.css" />    <link rel="stylesheet"type="text/css" href="CSS/demo.css" />    <script type="text/javascript"src="JS/jquery.min.js"></script>    <script type="text/javascript"src="JS/jquery.easyui.min.js"></script>  <div class="searchLock"style="width: 35%">                <divclass="panel-title">                    <h3class="panel-title">所有欄目</h3>                </div>                <div class="tlcorner">                </div>                <div class="trcorner">                </div>                <div class="blcorner">                </div>                <div class="brcorner">                </div>                <divclass="cnt-wp">                    <divclass="cnt">                         <tableid="tt" class="easyui-datagrid" style="height:210px" idfield="itemid"                           pagination="true"                          data-options="rownumbers:false,url:'JS/datagrid_data1.aspx',        pageSize:5,pageList:[5,10],        method:'get',toolbar:'#tb' ,"                           fitcolumns="true" striped="true">                            <thead>                                                                 <thdata-options="field:'ck',checkbox:true"></th>                                                    <thdata-options="field:'productid',width:100">Product</th><thdata-options="field:'listprice',width:80,align:'right'">ListPrice</th><thdata-options="field:'unitcost',width:80,align:'right'">UnitCost</th><thdata-options="field:'attr1',width:250">Attribute</th><thdata-options="field:'status',width:60,align:'center'">Status</th>                            </thead>                            <%--表格內容--%>                            <tbodyid="xianshi">                            </tbody>                         </table>                     </div>                </div>            </div>


function getSelections() {            var ss = [];            var rows =$('#tt').datagrid('getSelections');            if (rows.length > 0) {                if(confirm("確定添加選中記錄?")) {                      for (var i = 0; i <rows.length; i++) {                        var row = rows[i];                       //ss.push('<span>' + row.productid + ":" + row.attr1 +'</span>');                        ss.push(row.productid +"," + row.attr1 + "," + row.itemid + "," +row.listprice + "," + row.status);                     }                    var id = ss.join(',');                    var test ="addc";                    $.ajax({                        url:"SetMenun.ashx/ProcessRequest?id=" + id + "&test=" +test,                        success: function(text) {                            //grid.reload();                        },                        error: function () {                        }                    });                }                alert(id);             } else {                alert("請選中一條記錄");            }                                  $.messager.alert('Info',ss.join('<br/>'));        }

  一般處理常式

public class SetMenun : IHttpHandler    {        BLL.userColumInfoBLL columinfobll = newuserColumInfoBLL();        BLL.userMenuInfoBLL menuinfobll = newuserMenuInfoBLL();        BLL.columBLL columbll = new columBLL();        public void ProcessRequest(HttpContextcontext)        {            //context.Response.ContentType ="text/plain";           //context.Response.Write("Hello World");            string command =context.Request.QueryString["test"];            if (command == null)            {                QueryColum(context);            }            //添加選擇的欄目            if (command == "addc")            {                AddColum(context);            }            //添加選擇的菜單            if (command == "addm")            {                AddMenu(context);            }            //查詢欄目            if (command == "queryc")            {                QueryColum(context);            }            //添加選擇的欄目下的菜單            if (command == "querym")            {                QueryMenu(context);            }            //刪除欄目            if (command == "deletec")            {                DeleteColum(context);            }            //刪除菜單            if (command == "deletem")            {                DeleteMenu(context);            }               }  /// <summary>        /// 添加欄目記錄        /// </summary>        /// <paramname="context"></param>        public void AddColum(HttpContextcontext)        {            //實體            columEntity columEntity = newcolumEntity();            menuEntity menuEntity = newmenuEntity();            PublicClass test = newPublicClass();            string strresult = "";            //TODO:            //給實體迴圈賦值              //split方法將欄位進行篩選:            //TODO:需要親自驗證                     String[] list= context.Request.QueryString["id"].Split(',');             int count = list.Length;//if按照每個行資料轉送的欄位,進行遞增處理。             for (int i = 0; i < count;i=i+5)            {                //  欄目ID                columEntity.columID =i+1;                //欄目名稱                columEntity.cName = list[i];                columEntity.cAddress = list[i +1];                columEntity.cOpenType = list[i+ 2];                columEntity.cOrder = list[i +3];               // columEntity.columID =Convert.ToInt16( list[i + 4]);                //other1作為添加使用者                menuEntity.other1 =context.Server.UrlDecode(context.Request.QueryString["UserName"]);               test.SetObj(columbll);//調用相應介面下B層中的類                 try                {//調用公用處理類的方法。該方法匹配需要的類。                    if (test.Add(columEntity,null, null))                    {                        strresult=strresult+"true";                    }                    else                    {                        strresult =strresult+"false";                    }                }                 catch (System.Exception ex)                {                    throw ex;                }                    }            int number =strresult.IndexOf("false");            if (number == -1)            {               context.Response.Write("T");            }            else            {               context.Response.Write("F");            }        }}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.