sopt value to ignore case sensitivity - jqgrid

In my struts2jquery grid I've given
<sj:gridColumn name="processName" index="processName" title="Process Name" search="true" searchoptions="{sopt: ['bw','cn']}"/>
For sopt we've values like
{sopt:['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']}
Now I want to get the data in grid by ignoring the letter case. But it is filtering data if we search in the same way we stored. i.e; (say) If I stored data starting with 'D' it won't filter data starting with 'd'. How can I solve this. Is there any option for doing that?

this link should help you struts2 jquery plugin wiki grid.
you should define your own search action class to do the search. btw, it should be <sjg:gridColumn/> o_O

i found the solution with the JavaScript:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<%# taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
<div id="prije">Prije</div>
<s:url var="remoteurl" action="jsontable" />
<sjg:grid id="gridtableID"
caption="Primjer JSON TABELE"
dataType="json"
href="%{remoteurl}"
gridModel="gridModel"
viewrecords="true"
pager="true"
pagerPosition="centar"
navigator="true"
navigatorSearch="true"
filter="true"
filterOptions="{stringResult:true}"
loadonce="true"
>
<sjg:gridColumn name="id"
index="id" title="ID"
formatter="integer"
search="false"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"
editable="false" />
<sjg:gridColumn name="name" index="name" title="Name" sortable="true"
search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
<sjg:gridColumn name="country" index="country" title="Country"
search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
<sjg:gridColumn name="city" index="city" title="City" search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
<sjg:gridColumn name="creditLimit" index="creditLimit"
title="Credit Limit" formatter="currency" search="true"
searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
</sjg:grid>
<script>
$(document).ready(function(){
$("#gridtableID").jqGrid('setGridParam', { ignoreCase: true});
});
</script>

Related

Using spring form tag inside a custom JSTL library

I need to create a custom JSTL tag which wraps multiple spring form tags. A single tag which produces the below content with custom attribute values as well.
<div class="col-md-4 col-sm-6 cal-xs-12">
<div class="form-group">
<label for="statusCode">Employee Status Code: </label>
<form:input path="statusCode" class="form-control" id="statusCode" value="${statusCode}" />
</div>
</div>
Is this achievable?
create a file formInputFiled.tag inside WEB-INF/tags/form directory.
formInputFiled.tag:
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%# attribute name="id" required="true" rtexprvalue="true" %>
<%# attribute name="path" required="true" rtexprvalue="true" %>
<%# attribute name="label" required="true" rtexprvalue="true" %>
<%# attribute name="value" required="true" rtexprvalue="true" %>
<%# attribute name="parentDivClass" required="true" rtexprvalue="true" %>
<%# attribute name="divClass" required="true" rtexprvalue="true" %>
<%# attribute name="inputClass" required="true" rtexprvalue="true" %>
<div class="${parentDivClass}">
<div class="${divClass}">
<label for="${id}">${label}</label>
<form:input path="${path}" class="${inputClass}" id="${id}" value="${value}" />
</div>
</div>
Add taglib declaration in your jsp like below:
<%# taglib prefix="form" tagdir="/WEB-INF/tags/form" %>
Finally use the new tag like below:
<form:formInputFiled id="statusCode" path="statusCode" label="Employee Status Code:" value="${statusCode}" parentDivClass="col-md-4 col-sm-6 cal-xs-12" divClass="form-group" inputClass="form-control"/>

JSP kendo grid EDIT /ADD Handle ERROR response from spring rest Kendo UI v2015.3.1111

Trying Kendo UI JSP editable grid. Grid is working with few problems.
(Version : Kendo UI v2015.3.1111 )
Export: Even with allPages="allPages", its exporting only current
page.
After CREATE, GRID is not updated with server response which has user createDate. Same with Update, grid not updated with update date
even though the updated user object is passed.
Grid shows user added even if it failed in the backend. How to handle error response for create /update and show the failed message ?
Any help greatly appreciated.
Controller create part:
#RequestMapping(value = "/user/create", method = RequestMethod.POST)
public #ResponseBody User create(#RequestBody Map<String, Object> model) {
log.debug("create");
User target = new User();
target.setUserName((String)model.get("UserName"));
target.setFirstName((String)model.get("firstName"));
target.setLastName((String)model.get("lastName"));
target.setOpenDate(getDateFromStr((String)model.get("openDate")));
target.setEditDate(getDateFromStr((String)model.get("editDate")));
User user = userDao.createUser(target);
log.info("user"+user.getUserId()+user.getOpenDate());
return user;
}
JSP PART:
<c:url value="/user/create" var="createUrl" />
<c:url value="/user/read" var="readUrl" />
<c:url value="/user/update" var="updateUrl" />
<c:url value="/user/destroy" var="destroyUrl" />
<c:url value="/user/saveexcel" var="saveExcelUrl" />
<c:url value="/user/savepdf" var="savePdfUrl" />
<kendo:grid name="grid" pageable="true" sortable="true" height="750px" filterable="true">
<kendo:grid-scrollable/>
<kendo:grid-pdf fileName="KendoUIGridExport.pdf" allPages="allPages" proxyURL="${savePdfUrl}"/>
<kendo:grid-excel fileName="KendoUIGridExport.xlsx" allPages="allPages" proxyURL="${saveExcelUrl}" />
<kendo:grid-editable mode="popup" confirmation="Are you sure you want to remove this item?"/>
<kendo:grid-toolbar>
<kendo:grid-toolbarItem name="create"/>
<kendo:grid-toolbarItem name="excel"/>
<kendo:grid-toolbarItem name="pdf"/>
</kendo:grid-toolbar>
<kendo:grid-columns>
<kendo:grid-column title="User Name" field="userName" width="120px"/>
<kendo:grid-column title="First Name" field="firstName" width="120px" />
<kendo:grid-column title="Last Name" field="lastName" width="120px" />
<kendo:grid-column title="Open Date" field="openDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title="Edit Date" field="editDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title=" " width="150px">
<kendo:grid-column-command>
<kendo:grid-column-commandItem name="edit" />
<kendo:grid-column-commandItem name="destroy" />
</kendo:grid-column-command>
</kendo:grid-column>
</kendo:grid-columns>
<kendo:dataSource pageSize="10" serverPaging="false" serverSorting="false" serverFiltering="false" serverGrouping="false" >
<kendo:dataSource-transport>
<kendo:dataSource-transport-create url="${createUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-read url="${readUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-update url="${updateUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-destroy url="${destroyUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-parameterMap>
<script>
function parameterMap(options,type) {
return JSON.stringify(options);
}
</script>
</kendo:dataSource-transport-parameterMap>
</kendo:dataSource-transport>
<kendo:dataSource-schema>
<kendo:dataSource-schema-model id="userId">
<kendo:dataSource-schema-model-fields>
<kendo:dataSource-schema-model-field name="userName" type="string" >
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="firstName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="lastName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="openDate" type="date" editable="false" />
<kendo:dataSource-schema-model-field name="editDate" type="date" editable="false"/>
</kendo:dataSource-schema-model-fields>
</kendo:dataSource-schema-model>
</kendo:dataSource-schema>
</kendo:dataSource>
</kendo:grid>
Resolved myself: For pdf, allPages="true" works.
Grid refresh: FOR requestEnd event
function onRequestEnd(e) {
if (e.type == "create") {
e.sender.read();
}
else if (e.type == "update") {
e.sender.read();
}
}

Added orderable=true to Liferay search container, controls appeared but order does not change

I have written a Liferay search container, it works great.
Now I want columns to be sortable by alphabetical order, so I added orderable="true":
<liferay-ui:search-container
<liferay-ui:search-container-results
results="<%= BicycleLocalServiceUtil.getBicyclesByCompanyId(
themeDisplay.getCompanyId()) %>"
total="<%= BicyleLocalServiceUtil.getBicyclesCount() %>" />
<liferay-ui:search-container-row
className="com.example.portal.portlet.navigation.model.Bicycle"
keyProperty="bicycleId"
modelVar="bicycle"
escapedModel="<%= true %>">
<liferay-ui:search-container-column-text
name="name"
property="name"
value="<%= bicycle.getName() %>"
orderable="<%= true %>"
/>
<liferay-ui:search-container-column-text
name="nickname"
property="nickname"
orderable="<%= true %>"
/>
<liferay-ui:search-container-column-jsp
align="right"
path="/html/bicycle/bicycle_actions.jsp" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
The results looks good: but when I click on the name or any of the small arrows, the order of the rows below does not change.
Am I missing something?
I don't need any custom comparator as the value are simple Strings such as "Bob" and "Joe".
You need to specify the oderableProperty:
<liferay-ui:search-container-column-text
name="nickname"
property="nickname"
orderableProperty="nickname"
orderable="<%= true %>"
/>

Set a value for <form: input> in Spring's form tag library

How can I possibly set a value for a form input field using the form tag library in Spring MVC shown below even if it has no value attribute and is not accepted according to form tld?
<form:input path ="name" id="name" cssStyle="display: none"/>
Not based on requirement:
<input type="hidden" id="name" value="Raven"/>
Don't use a <form:input>? It's for binding to beans.
You can use a regular <input> element ;)
If you want to set its value:
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:set var="name" value="Raven" />
<input type="hidden" name="name" value="<c:out value='${name}' />" />

How to make Struts and Prototype work better together?

Prototype library uses $('element-id') or $F('element-id') to get the element or value of a form element. This is very convenient to code in javascript. But in Struts, I find there is no way to define an id attribute for a form element.
Although i can use
<html:xhtml/>
to define a form tag with id attribute as follows:
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<%# taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%# taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<html:xhtml/>
<html:form action="/Welcome">
...
<html:text property="username" size="16" maxlength="18"/>
...
</html:form>
The above rendered html is like this:
<form id="TestForm" method="post" action="/myapp/Welcome.do">
...
<input type="text" name="username" size="16" maxlength="18"/>
...
</form>
But what i need is to let struts render the
<html:text>
tag like this:
<input type="text" id="username" name="username" size="16" maxlength="18"/>
So is it possible in Struts to realize that? Or if not, how can i make it better to code in Prototype lib for Struts application?
I am using Struts 1.3.8; Prototype 1.5.1.
You can use the styleId attribute on most Struts widgets to set the HTML element id:
<html:text styleId="myId" .../>
renders as
<input type="text" id="myId" .../>

Resources