73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
namespace YLErp.Helpers
|
|
{
|
|
public class JqGridSimple
|
|
{
|
|
//0gridindex,1 dataurl,2 other property like multiselect:true, , rownumbers: true, height: {3} ,showfooter:{4}
|
|
const string script = @"
|
|
var __jq={{
|
|
PostData :typeof PostData{0} !=='undefined'?PostData{0}:{{}},
|
|
AfterInsertRow :typeof AfterInsertRow{0} !=='undefined'?AfterInsertRow{0}:void 0,
|
|
rowclick :typeof rowclick{0} !=='undefined'?rowclick{0}:void 0,
|
|
rowdblclick :typeof rowdblclick{0} !=='undefined'?rowdblclick{0}:void 0,
|
|
gridComplete :typeof gridComplete{0} !=='undefined'?gridComplete{0}:void 0,
|
|
onJqgridPaging :typeof onJqgridPaging{0} !=='undefined'?onJqgridPaging{0}:void 0
|
|
}};
|
|
|
|
var grid{0}=jQuery('#listGrid{0}').jqGrid({{
|
|
url: '{1}',
|
|
datatype: 'json',
|
|
{2}
|
|
height: '{6}',
|
|
width: '90%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: {{ repeatitems: false }},
|
|
cmTemplate: {{align:'center',width: 120}},
|
|
mtype: 'POST',
|
|
postData: __jq.PostData,
|
|
afterInsertRow: __jq.AfterInsertRow,
|
|
onSelectRow:__jq.rowclick,
|
|
ondblClickRow:__jq.rowdblclick,
|
|
colModel: colModelGrid{0},
|
|
pager: jQuery('#pagerGrid{0}'),
|
|
pagerpos:'left',
|
|
rowNum: {5},
|
|
rowList: [20, 30, 50,200,500,10000],
|
|
loadComplete:__jq.gridComplete,
|
|
onPaging: __jq.onJqgridPaging,
|
|
footerrow: {4}
|
|
}});";
|
|
|
|
const string tag = "<table id='listGrid{0}' class='scroll' cellpadding='0' cellspacing='0' ></table><div id='pagerGrid{0}' ></div>";
|
|
|
|
public static string OutGrid(string path, bool isMultiSelect = false, bool isShowFooter = false, int? num = null,int rowNum=20,string height= "auto")
|
|
{
|
|
const string setheight = "'800px',";
|
|
string multiSelect = isMultiSelect ? "multiselect:true," : string.Empty;
|
|
return string.Format(script, num?.ToString(), path, multiSelect, setheight, isShowFooter ? "true" : "false", rowNum,height);
|
|
}
|
|
|
|
public static string OutTable(int? num = null)
|
|
{
|
|
return string.Format(tag, num?.ToString());
|
|
}
|
|
|
|
|
|
#region 镒链的模板
|
|
const string _ycTag = "<table id='listGrid{0}' class='table table-bordered table-hover' cellpadding='0' cellspacing='0' ></table><div id='pagerGrid{0}' ></div>";
|
|
|
|
public static string YcOutGrid(string path, bool isMultiSelect = false, bool isShowFooter = false, int? num = null)
|
|
{
|
|
const string setheight = "'800px',";
|
|
string multiSelect = isMultiSelect ? "multiselect:true," : string.Empty;
|
|
return string.Format(script, num?.ToString(), path, multiSelect, setheight, isShowFooter ? "true" : "false");
|
|
}
|
|
|
|
public static string YcOutTable(int? num = null)
|
|
{
|
|
return string.Format(_ycTag, num?.ToString());
|
|
}
|
|
#endregion
|
|
}
|
|
} |