jessite框架前台显示数据的几种方法

1.自定义标签获取字典数据,即在js脚本中通过jstl自定义标签引入,并根据获取的数据动态显示出自己需要的数据,如下代码红色部分,当前场景没有用到,但是可以作为一种方法去了解。

gridComplete: function () 
	    var ids = jQuery("#grid-table").jqGrid('getDataIDs');
	    for (var i = 0; i < ids.length; i++) {
		    var id = ids[i];
		    var rowData = $("#grid-table").getRowData(id);  
		    var materialType = getDictLabel(${fns:toJson(fns:getDictList("material_type"))}, type);
		    var type = rowData ['status'];
		    var str;
		    switch (type) {
			    case "0":
			    str = "class=\"label label-info\"><p style=\"margin-top:2px\">未解决";
			    break;
			    case "1":
			    str = "class=\"label label-warning\"><p style=\"margin-top:2px\">已解决";
			    break;
		    }
		    str = "<span style=\"border-radius:4px;\" " + str + "<\p><\span>";
		    $(grid_selector).jqGrid('setRowData', ids[i], {
		    	status:str
		    }); 
	    }
	    $(grid_selector).find('[data-action=makePlan]').on('click', function (event) {
	    var id = $(this).attr('data-id');
	    //超链接跳到计划制定页面 
	    alert("超链接跳到订单页面");
	    });
    }

2.后台返回到前台具体地址时携带一个list数据,通过‘c’标签循环遍历显示出数据。value代表实际值,option中的代表显示的值,当前item.orderNumber可以改成item.id,这样不影响前端显示结果,只是传给后台数据进行查询时,会将通过编号查询的方式换成通过id方式查询,因为你此时传的值实际是id的值。(通常用于查询条件)

<label class="control-label col-xs-12 col-sm-2 no-padding-right" for="orderNumber">订单编号: </label>
	<div class="col-xs-12 col-sm-3">
		<select id="orderNumber" name="orderNumber" class="chosen-select form-control" data-placeholder="点击选择订单编号...">
			<option value=""></option>
			<c:forEach items="${orderRecorderNumberList}" var="item" varStatus="idxStatus">
			<option value="${item.orderNumber}" htmlEscape="false"> ${item.orderNumber} </option>
			</c:forEach>
		</select>
	</div>

3.spring form和“c”标签相结合接收后台传来的list并且进行标签循环输出。

<form:select path="orderNumber" class="chosen-select form-control width-100" data-placeholder="点击选择...">
		<form:option value="" htmlEscape="false"/>
		<c:forEach items="${orderFormList}" var="item" varStatus="idxStatus">
			<form:option value="${item.orderNumber}" htmlEscape="false"/>
		</c:forEach>
	</form:select>

4..在Spring form和数据字典的方式的方式,form:options,form:select格式选择加字典的方式获取所有list数据(单一实体类),label表示当前页面所显示的,value代表实际的值。(通常用于编辑表中某一行字段),当然,也可以引入相应标签作为逻辑判断.

<label class="control-label col-xs-12 col-sm-2 no-padding-right" for="status">订单状态:</label>
<div class="col-xs-12 col-sm-3">
	<form:select path="status" class="chosen-select form-control width-100" data-placeholder=" 点击选择...">
		<form:option value="" htmlEscape="false"/>
		<form:options items="${fns:getDictList('hy_order_form_record_status')}" itemLabel="label" itemValue="value" htmlEscape="false" />
	</form:select>
	</div>
	<c:choose>
		<c:when test="${office.type == 1}">
			<input type="text" id="officetype" readonly="" class="form-control" name="officetype" value="${fns:getDictLabel(office.type, 'sys_office_type', '')}"/>
			<input type="hidden" id="type" class="form-control" name="type" value="${office.type}"/>
		</c:when>
		<c:otherwise>
			<form:select path="type" class="chosen-select form-control width-100" data-placeholder="点击选择...">
				<form:options items="${fns:getDictList('sys_office_type')}" itemLabel="label" itemValue="value" htmlEscape="false" />
			</form:select>
		</c:otherwise>
	</c:choose>
</div>

猜你喜欢

转载自blog.csdn.net/CEVERY/article/details/83856005