---
title: "FlexGrid动态传参的做法 "
author: "sweetyang"
date: "2014-04-10T10:11:00Z"
tags: []
categories: ["Web前端"]
slug: "flexgrid"
draft: false
lastmod: "2014-04-10T10:12:14Z"
id: 2042845
url: "https://sweetyang.iteye.com/blog/2042845"
---

思路：通过ajax动态传JSON方式。回调FlexGrid的flexReload方式实现。

 

js:

```
$("#flexTable").flexigrid({
			width: 700 ,
			height: 150,
			url: 'workform-function-main!getWbfDetailGridSummaryDate.action',
			dataType: 'json',
			colModel : [
			        	{display: '序号', name : 'id', width : 50, sortable : true, align: 'center',hide: true,toggle : false},
			        	{display: '工单编码', name : 'workformid', width : 80, sortable : true, align: 'center'},
			        	{display: '节点编号', name : 'nodeid', width : 80, sortable : true, align: 'center'},
			        	{display: '出单点名称', name : 'orderorg', width : 80, sortable : true, align: 'center'},
			        	{display: '分配给', name : 'distribute', width : 80, sortable : true, align: 'center'},
			        	{display: '节点状态', name : 'nodestate', width : 80, sortable : true, align: 'center'},
			        	{display: '节点名称', name : 'nodename', width : 250, sortable : true, align: 'center'}
				],
			errormsg: '发生异常',
			sortname: "id",
			sortorder: "desc",
			usepager: false,
			useRp: false,
			nomsg: '没有符合条件的记录存在',
			minColToggle: 1, //允许显示的最小列数
			showTableToggleBtn: true,
			autoload: true, //自动加载，即第一次发起ajax请求
			resizable: true, //table是否可伸缩
			procmsg: '加载中, 请稍等 ...',
			hideOnSubmit: true, //是否在回调时显示遮盖
			showcheckbox: false,//是否显示第一列的checkbox（用于全选）
			gridClass: "bbit-grid",//样式
			rowbinddata: true,//配合上一个操作，如在双击事件中获取该行的数据
			striped:false,
			blockOpacity: 0.5//透明度设置
		});
```

 

 

Js代码 [![复制代码](http://longflang.iteye.com/images/icon_copy.gif)](http://longflang.iteye.com/blog/1149008 "复制代码") [![收藏代码](http://longflang.iteye.com/images/icon_star.png)![](http://longflang.iteye.com/images/spinner.gif)]()

01. **function** gridFlash(){
02. **var** params = {'username':$("#username").val()};
03. $.post(
04. "workform-main!getData.action",
05. params,
06. **function**(){
07. $("#flexTable").flexReload();
08. }
09. );
10. }