拼接的資料顯示
不同的格式顯示
引入的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"); } }}