0

Once again I'm stuck using the jqGridin Struts2 with struts2-jquery plugin. This time I wanted to put a <select/>field in the search dialog for a column, as done in this tutorial here.

I built and tested the action supposed to return JSP with the select and all populated values inside of it and it works fine, I think the issue relates fully to jqGrid. Maybe I'm overlooking something here.

When I open the search popup and select the column I want to search for (the one with the select set), it triggers the action which retrieves the data and then a select input appears but with no data inside it, it appears to be null, so I have an empty select.

Below I'm posting some of my code:

jqGrid global config:

 <sjg:grid
        id="resGrid"
        altRows="false"
        caption="%{getText('reservationTable.title')}"
        dataType="json"
        href="%{remoteurl}"
        editurl="%{deleteUrl}"
        pager="true"
        gridModel="gridModel"
        rowList="10,15,30"
        rowNum="15"
        navigator="true"
        navigatorSearch="true"
        autowidth="true"
        navigatorAdd="false"
        onDblClickRowTopics="rowSelect"
        navigatorEdit="false"
        navigatorDelete="false"
        navigatorSearchOptions="{
                multipleSearch: true, 
                closeAfterSearch: true,
                afterRedraw: afterRedraw
        }"
        navigatorExtraButtons="{
                photos : { 
                        title : '%{getText('reservationTable.icon.photo')}', 
                        icon: 'ui-icon-image', 
                        onclick: showPhotos,
                        position: 'first'
                }
        }"
        >

jqGrid column config:

<sjg:gridColumn name="execution" 
index="execution" 
title="%{getText('execution')}" 
formatter="execution" 
search="true" 
searchtype="select" 
searchoptions="{ sopt:['eq'], 
                 dataUrl:'%{selecturl}', 
                 value: ':All;'}"/>

Result from retrieving the data (copied from the tutorial I linked above, this works fine):

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<s:select list="executionStrValues" theme="simple" emptyOption="true"/>

I've been stuck with this for a couple of days and I made some research, I found that this script could be useful as in this link HERE this issue with jqGrid is discussed on Github. I used it like this:

 <script type="text/javascript">
(function() {
    $.jgrid = {
            defaults : {
                ajaxSelectOptions: 'GET',
                async: false
            }
        }
})();
</script> 

This other open issue relates to this topic aswell: LINK
I also saw some people suggest using the formatter="select"for the row, but if I understood correctly I don't need it because I'm not inline editing this column as written in the documentation.


UPDATE: ACTION CONFIGURATION Below my <s:url> which triggers the action returning values and the action's configuration:

<s:url var="selecturl" action="getExecutionStatus" />

getExecutionStatus.action where ExecutionStatus is an enum:

@ResultPath(value = "/")
public class UtilsAction extends ActionSupport {

    private static final long serialVersionUID = 3672057774005126256L;
    private List<String> executionStrValues;

    @Action(value="getExecutionStatus", results={
            @Result(name="success",location="jsp/selectExecution.jsp"),
            @Result(name="input", location="jsp/error.jsp"),
            @Result(name="login", location="index.jsp")
            })
    public String getExecutionValues(){

        List<ExecutionStatus> executionValues = Arrays.asList(ExecutionStatus.values());
        executionStrValues = new ArrayList<String>();

        for(ExecutionStatus ex: executionValues)
            executionStrValues.add(getText("executionStatus."+ex.toString()));


        return SUCCESS;

    }//getExecutionValues

    public List<String> getExecutionStrValues() {
        return executionStrValues;
    }

    public void setExecutionStrValues(List<String> executionStrValues) {
        this.executionStrValues = executionStrValues;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }
}
JorgeGRC
  • 1,032
  • 2
  • 18
  • 37
  • Show your `selecturl` action class and configuration. – Aleksandr M Dec 11 '14 at 19:57
  • @AleksandrM any new thoguhts? I'm still stuck with this and have no idea what can be going wrong.. – JorgeGRC Dec 16 '14 at 08:40
  • If your `ExecutionStatus` is an enum why do you need an action to fetch it? You can just use it in select tag - http://stackoverflow.com/q/16063819/1700321. – Aleksandr M Dec 16 '14 at 09:46
  • @AleksandrM because it's the way the jqgrid plugin works to populate a select inside a search field with that enum's values.. I don't really know another way to go around it – JorgeGRC Dec 16 '14 at 09:51

1 Answers1

0

put it your jsp page. i think it works. <%@taglib prefix="s" uri="/struts-tags"%> <%@taglib prefix="sj" uri="/struts-jquery-tags"%> <%@taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>

bhanuja
  • 16