datagrid问题,跪求大神帮忙解决

塔塔塔吖 2016-12-19 04:00:53
easyui datagrid后台显示数据之前先判断怎么写,比如用户类型是管理员的就不要在页面显示?用户类型有:1、附属用户;2、注册用户;3、管理员,在用户管理模块只显示附属用户和注册用户。
public ActionResult Query(int page = 1, int rows = 30, string sort = "U_ID", string order = "desc")
{

Expression<Func<TB_User, dynamic>> select = n => new
{
U_ID = n.U_ID,
U_NAME = n.U_NAME,
U_PWD = n.U_PWD,
U_TYPE = n.U_TYPE,
U_LastDate = n.U_LastDate,
U_SHOW_Name = n.U_SHOW_Name,
U_Mail = n.U_Mail,
U_Phone = n.U_Phone,
U_Fixed = n.U_Fixed,
U_Line = n.U_Line,
U_Line_Pwd = n.U_Line_Pwd,
};
bool ascending = true;
if (!string.IsNullOrEmpty(order) && order == "desc")
{
ascending = false;
}
Expression<Func<TB_User, bool>> where = (n => true);
if (!string.IsNullOrEmpty(Request["U_ID"]))
{
try
{
int ss = Convert.ToInt32(Request["U_ID"]);
where = where.And(n => n.U_ID == ss);
}
catch
{

}
}
if (!string.IsNullOrEmpty(Request["U_NAME"]))
{
string sName = Request["U_NAME"];
where = where.And(n => n.U_NAME.Contains(sName));
where = where.Or(n => n.U_SHOW_Name.Contains(sName));
}
int totalRecord = 0;
var data = userDal.getPageDate(select, where, sort, ascending, page, rows, out totalRecord);
Hashtable hb = new Hashtable();
hb["total"] = totalRecord;
hb["rows"] = data;
return Json(hb, "text/html", JsonRequestBehavior.AllowGet);
}
...全文
82 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
塔塔塔吖 2016-12-20
  • 打赏
  • 举报
回复
嗯嗯呢,谢谢你
Go 旅城通票 2016-12-19
  • 打赏
  • 举报
回复
自己session记录住登录用户的权限,依据session的值是否增加类型就行了,数据接口也一样注意加判断。。 如果你不在意客户端是否显示类型那列,就是不管是管理员或者普通用户都显示,只需要修改数据接口,管理员就返回类型数据,否则不返回就行,类型那列自然为空

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧