jqGrid 展示数据、获取查询条件进行查询案例

jqGrid 展示数据、获取查询条件进行查询案例_第1张图片

如图,用jqgrid实现 数据的展示

html:

    

数据展示 js:

    function gridList() {
        var yyjdata = document.getElementById("CurrentState1").value;  //原业绩所属代表处
        var tzlx = document.getElementById("CurrentState2").value;  //调整类型
        debugger;
        var cplx = document.getElementById("CurrentState").value;   //产品类型
        var $gridList = $("#gridList");
        debugger;
        $gridList.dataGrid({
            data: {
                yyjdata: yyjdata,
                tzlx: tzlx,
                cplx: cplx
            },
            url: "GetService", //SelectIT
            height: "100%",
            shrinkToFit: true,
            rowNum: 15,
            rowList: [15, 30, 50],
            pager: "#gridPager",
            multiselect: true,//复选框
            viewrecords: true,
            autowidth: true,

            //multiselect: true, //多选框 
            sortorder: 'desc',
            rownumWidth: 25,
            rownumbers: true,
            cellEdit: true,
            cellsubmit: 'clientArray',
            //colNames: ['订单号', '项目名称', '办事处', '项目类型', '系统部', '扩展部', '报单销售', '销售工号', '', '', ''],
            colNames: ['','代理商编码', '出货代理商', '项目名称', '调整金额(万)', '产品业绩归属', '主机序列号', '调整后对应销售代表处', '调整后对应地市', '调整后对应销售部门', '调整后对应行业', '调整后对应拓展部', '调整后对应销售代表工号', '调整原因简述', '操作', '删除' ],  //'撤回',//'调整后对应销售代表',
            colModel: [
                {
                    name: 'T_ID', align: 'center', width: '90px;', key: true ,hidden:true
                },  {
                    name: 'IT_OUTAGENTID', align: 'center', width: '90px;', 
                }, {
                    name: 'IT_OUTAGENT', align: 'center', width: '135px;'
                }, 
                {
                    name: 'IT_PRODUCTNAME', align: 'center', width: '70px'
                    //, formatter: function (cellvalue, options, rowObject) {
                    //    var _href = "/Others/CBSTransfer/DetailsPage"; 
                     //var url = "" + rowObject["SerialNum"] + "";
                    //    return url; 
                    //}
          
                    , formatter: function (cellvalue, options, rowObject) {
                        debugger;
                        if (rowObject["TASKID"] == null) { 
                            var _href = "/Others/CBSTransfer/DetailsPageNOThaveProcess";
                            var url = "" + cellvalue + "";
                            return url; 
                        } else {  
                            var _href = "/Others/CBSTransfer/DetailsPage";
                            var url = "" + cellvalue + "";
                            return url;
                        }
                        
                    }
                },
                {
                    name: 'T_MONRY', align: 'center', width: '90px;'
                },
                {
                    name: 'IT_BELONGCLASSLY', align: 'center', width: '90px;'
                },
                {
                    name: 'IT_PRODUCTTYPE', align: 'center', width: '90px;'
                },
                {
                    name: 'T_REGION2', align: 'center', width: '90px;'
                },
                {
                    name: 'T_REGION3', align: 'center', width: '90px;'
                },
                {
                    name: 'T_PROJECT_TYPE', align: 'center', width: '90px;'
                },
                {
                    name: 'T_INDU1', align: 'center', width: '90px;'
                },
                {
                    name: 'T_INDU2', align: 'center', width: '90px;'
                },
                //{
                //    name: 'REMARK', align: 'center', width: '100px;' 
                //},
                {
                    name: 'T_SALE', align: 'center', width: '90px;'
                },
                {
                    name: 'T_CONTNT', align: 'center', width: '90px;'
                },
                {
                    name: 'T_ID', align: 'center', width: '100px;', formatter: function (cellvalue, options, rowObject) {
                        if (rowObject["T_STATIC"] == "审批中" || rowObject["T_STATIC"] == "审批完成")
                            return "已提交";
                        else
                            return "提交";
                    }
                }, 
                {
                    name: 'IT_ID', align: 'center', width: '90px;', formatter: function (cellvalue, options, rowObject) {
                        if (rowObject["T_STATIC"] == "审批中")
                            return "中止";
                        else if (rowObject["T_STATIC"] == "审批完成") 
                            return "审批完成"; 
                        else
                            return "删除";
                    }
                }

                
            ],
            beforeEditCell: function (rowid, cellname, value, iRow, iCol) {
                row = rowid;
                col = iCol;
            },
            afterSaveCell: function (rowid, name, val, iRow, iCol) {
                var row = $("#gridList").jqGrid('getRowData', iRow);

            },


        });
    }

数据展示 c#后台代码:


		/// 
		/// 获取调整后的业绩    
		/// 
		/// 
		/// 
		public JsonResult Get_TZ_TransferCT(string Project_Id, string task_id, string regionid, string programname, string current_state)
		{

			int page = 1;
			int rows = 15;
			if (!string.IsNullOrWhiteSpace(Request["page"]))
			{
				page = int.Parse(Request["page"]);  //当前页码
			}
			if (!string.IsNullOrWhiteSpace(Request["rows"]))
			{
				rows = int.Parse(Request["rows"]);  //每页显示的条数 
			}
			var code = ServiceContext.GetUserInfo().UserCode;//获取当前登录人
			var com = Request["com"] == null ? null : Request["com"] == "未提交" ? null : "已提交";
			Dictionary dic = new Dictionary();
			dic.Add("taskid", task_id);
			//dic.Add("codeperson", code);
			dic.Add("com", com);
			dic.Add("pageStartIndex", ((page - 1) * rows).ToString());       //从第几条数据开始
			dic.Add("pageEndIndex", (page * rows).ToString());               //到第几条数据结束

			dic.Add("regionid", regionid);
			dic.Add("programname", programname);
			dic.Add("current_state", current_state);
			var tp = SQLAction.SqlMapGetList("Get_ct_data", dic);//Get_cbs_data
			Dictionary diccount = new Dictionary();

			//dic.Add("type1", type);
			//dic.Add("protype1", protype);//产品类型
			//dic.Add("codeperson", code);//区别在于所有人都能看的见 
			if (!string.IsNullOrEmpty(regionid))
			{
				dic.Add("regionid1", regionid);
			}
			if (!string.IsNullOrEmpty(programname))
			{
				dic.Add("programname1", programname);
			}
			if (!string.IsNullOrEmpty(current_state))
			{
				dic.Add("current_state1", current_state);
			}
			var tpcount = SQLAction.SqlMapGetT("Get_ct_dataCount", diccount);
			List list = new List();
			list.AddRange(tp);
			SqlBackItem SqlBackItem = new SqlBackItem();
			SqlBackItem.rows = list;
			SqlBackItem.records = tpcount;
			return PubClass.MyJson(SqlBackItem, "yyyy-MM-dd HH:mm:ss", JsonRequestBehavior.AllowGet);
		}

查询页面 html:

            审批状态:
            
                
            

            代理商编码:
            
                
            

            项目名称:
            
                
            
            原业绩所属代表处:
            
                
            

查询功能js:   


    //it查询
    $("#btn_search_s").click(function () {
        var region_id = document.getElementById("txt_regionid").value;//代理商编码
        var program_name = document.getElementById("txt_programname").value; //项目名称
        var current_state = $("#CurrentStateCom").val();//获取审批状态

        

        var $gridList = $("#gridList");
        $gridList.jqGrid('setGridParam', {
            postData: {
                regionid: region_id,
                programname: program_name,
                current_state: current_state,
                page: 1
            }
        }).trigger('reloadGrid');
    });

 

你可能感兴趣的:(IT,technology,js)