Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
strut2 jquery plugin - grid table - 2 questions
13/01/2010
23:29
Avatar
ram2010
Member
Members
Forum Posts: 43
Member Since:
13/01/2010
sp_UserOfflineSmall Offline

Hi, I am trying to implement jquery in particular to use the Edit Grid functionality. I am new to jquery & the jquery plugin for struts.

I need some help with regards a couple of questions I have.

1) Select option(dropdown list) in a column & pre-populating the data from a call to the server.

According to the jgrid wiki, to retrieve the details to be in the dropdown list, you specify a dataUrl.

Below is what I have been trying to do but withouth success.

editoptions="{dataUrl:/building/listAllAreas.action}" 

my action I have in my struts.xml file as follows:

  <action name="listAllAreas" class="com.test.MyGridTableAction" method="findAllAreas">
      <result type="json" name="success">
      <param name="excludeProperties">service</param>
     </result>
 </action>

I am unsure if what I am doing is the correct way to retrieve a list and put into a select box in a gridColumn. If anyone has any struts2 jquery examples, I would really appreciate it as it would help a lot.

2) When 'filter' is set to true in sj:grid, it puts a row at the top of the table and all editable columns will have a textfield that can be used for searching. When values are entered in this filter textbox, it automatically makes a call to my action class. however at the moment I am unsure as to what variable I should be checking in my action class to retrieve the value entered by the user.

How do I check the value that is searched when using the filter option? 

I added filter="true" in the struts2-jquery-showcase-1.8.1(Grid Editable section) to test this out, but It didnt seem to work. Nothing was being filtered.

Thanks in advance

14/01/2010
12:41
Avatar
jogep
Germany
Member
Members
Forum Posts: 23
Member Since:
14/01/2010
sp_UserOfflineSmall Offline

To your first Question:

Create an Simple Struts2 Action like this:

public class CustomerCountrys extends ActionSupport {
  private List<String>      countrys;
  private CustomersDao customersDao = new CustomersDao();

  private static final long serialVersionUID = 6721064966173343669L;

  @Action(value = "/customer-countrys", results = {
    @Result(location = "customer-countrys.jsp", name = "success")
  })
  public String execute() throws Exception
  {
    countrys = customersDao.findCountrys();
    return SUCCESS;
  }
 
  public List<String> getCountrys()
  {
    return countrys;
  }
}

Your customer-countrys.jsp should be simple like this:

<%@ taglib prefix="s" uri="/struts-tags"%>
<s:select list="countrys" theme="simple"/>

Your gridColumn can look like this:

    <s:url id="selecturl" action="customer-countrys" />

        <sj:gridColumn
            name="country"
            index="country"
            title="Country"
            sortable="true"
            editable="true"
            edittype="select"
            editoptions="{ dataUrl : '%{selecturl}' }"
            />

Hope this helps you.

14/01/2010
14:37
Avatar
ram2010
Member
Members
Forum Posts: 43
Member Since:
13/01/2010
sp_UserOfflineSmall Offline

Thanks that seemed to work fine. Thanks again. The dropdown list gets populated when I click on the column. Is there a way to ensure that its already pre-populated as the grid loads?

I think I figured out the answer to my 2nd question on the filtering. I noticed there is a parameter passed into the action called: _search. This wil be set to true when a filter is used for searching.

The 'index' attribute set in the sj:gridColumn will contain the value the user enters in the filter. By having a getter method in the action class matching the value of index, you can then acertain the value.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
62 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information