迁移也没太大变化,有一个, 之前的Request.QueryString 是返回NameValueCollection, 现在则是返回整个字符串. 你要改成Request.Query[“key”]
直接上代码吧.
1 @using FoxCRMCore 2 @{ 3 var controller = "CRM/Announcement"; 4 ViewBag.Title = "公告信息"; 5 } 6 7 8 <script type="text/javascript" language="javascript"> 9 10 $(function () { 11 12 $('#grid').datagrid({ 13 title: '@ViewBag.Title', 14 iconCls: 'icon-blank', 15 nowrap: false, 16 striped: true, 17 url: '/@controller/ListByPage', 18 sortName: 'cDate', 19 sortOrder: 'desc', 20 remoteSort: true, 21 fitColumns: true, 22 fit: true, 23 idField: 'id', 24 frozenColumns: [[ 25 { field: 'id', checkbox: true, width: 50, sortable: true }, 26 { field: 'OPERATION', title: '编辑', width: 50, formatter: 27 function (value, row, index) { 28 29 var edit = '<a href="/@controller/View/' + row.id + '">编辑</a> '; 30 return edit; 31 } 32 } 33 ]], 34 35 columns: [[ 36 { field: 'subject', title: '标题', width: 150, align: 'right', sortable: true }, 37 { field: 'contentDesc', title: '内容', width: 500, align: 'left', sortable: true }, 38 { field: 'cDate', title: '创建时间', width: 120, align: 'right', sortable: true }, 39 { field: 'modifyDate', title: '修改时间', width: 120, align: 'right', sortable: true }, 40 { field: 'isActive', title: '是否有效', width: 50, align: 'right', sortable: true } 41 ]], 42 onDblClickRow: function (index, data) { 43 var row = $(this).datagrid('getRows')[index]; 44 window.location = "/@controller/View/" + row.id; 45 }, 46 pagination: true, 47 pageSize: 10, 48 rownumbers: true, 49 toolbar: "#dlg-toolbar" 50 }); 51 52 $('#grid').datagrid('gotoPage', 2); 53 }); 54 55 //SearchBox传value过来,不能用$('#txtKey').val() 56 function Search(value, name) { 57 $('#grid').datagrid('load', { "key": "Air", "value": value }); 58 } 59 function Add() { 60 window.location = "/@controller/View/"; 61 } 62 function Edit() { 63 64 var row = $('#grid').datagrid('getSelected'); 65 if (row) { 66 window.location = "/@controller/View/" + row.id; 67 } 68 else { 69 $.messager.alert('提示', '请选择要修改的数据'); 70 return; 71 } 72 } 73 function Delete() { 74 var rows = $('#grid').datagrid('getSelections'); 75 if (!rows || rows.length == 0) { 76 $.messager.alert('提示', '请选择要删除的数据'); 77 return; 78 } 79 var parm; 80 $.each(rows, function (i, n) { 81 if (i == 0) { 82 parm = "idList=" + n.id; 83 } 84 else { 85 parm += "&idList=" + n.id; 86 } 87 }); 88 $.messager.confirm('提示', '是否删除这些数据?', function (r) { 89 if (!r) { 90 return; 91 } 92 93 $.ajax({ 94 type: "POST", 95 url: "/@controller/Delete/", 96 data: parm, 97 success: function (msg) { 98 if (msg.IsSuccess) { 99 $.messager.alert('提示', '删除成功!', "info", function () { 100 $('#grid').datagrid("reload"); 101 }); 102 } 103 }, 104 error: function () { 105 $.messager.alert('错误', '删除失败!', "error"); 106 } 107 }); 108 }); 109 } 110 111 </script> 112 113 114 <div region="center" style="padding: 5px;" border="false"> 115 <table id="grid"> 116 </table> 117 </div> 118 <div id="dlg-toolbar" style="padding: 2px 0;display:none"> 119 <table cellpadding="0" cellspacing="0" style="width: 100%"> 120 <tr> 121 <td style="padding-left: 2px"> 122 <a id="btnSave" href="javascript:Add();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"> 123 添加</a> @*<a id="btnUpdate" href="javascript:Edit();" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true"> 124 修改</a> <a id="btnDelete" href="javascript:Delete();" class="easyui-linkbutton" data-options="iconCls:'icon-cut',plain:true"> 125 删除</a>*@ 126 <input id="txtKey" class="easyui-searchbox" data-options="prompt:'请输入查询条件',searcher:Search" style="width: 250px" /> 127 </td> 128 </tr> 129 </table> 130 </div>