2

I have the following code to show my results in a table, I am wondering, how I can change it to be able to edit the records?

I want to edit records and sort based on specific column, currently I can sort them but I do not know how to edit them.

<display:table id="txt" name="employees" requesturi="" pagesize="10" cellpadding="2px;" cellspacing="2px;" style="margin-left:450px;margin-top:20px;">
<display:column property="employeeCode" title="Employee Code" sortable="true"></display:column>
<display:column property="employeeName" title="Employee Name" sortable="true"></display:column>
<display:column property="department" title="Department" sortable="true"></display:column>
<display:column property="salary" title="Salary" sortable="true"></display:column>
</display:table>

I've found the following code as well but I am wondering if there is any other approach to the issue?

Link

Roman C
  • 49,761
  • 33
  • 66
  • 176
AlexCartio1
  • 238
  • 3
  • 9
  • 29

2 Answers2

2

For example, changing your columns from

<display:column property="employeeName" title="Employee Name" sortable="true">
</display:column>

to something like

<display:column title="Employee Name" sortable="true">
    <s:textfield name="employeeName" value="%{#attr.txt.employeeName}" />
</display:column>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • 1
    thanks, but in this way I should have a single submit btn to submit the form with all the fields am I right? – AlexCartio1 Feb 26 '14 at 21:58
  • Sorry but nowhere in the question was mentioned you want to edit row by row (with a button on each row ? Through AJAX, via GET or via POST ?). Since you are starting, it would be nice to take a look at something newer than displaytag, engineered basing on the last 10 years of problems like yours: [Struts2 jQuery Grid](http://struts.jgeppert.com/struts2-jquery-grid-showcase/index.action). – Andrea Ligios Feb 27 '14 at 10:13
0

You can send single row data to javascript function when clicking on edit link or button and then open pop-up window which display data and user can edit data.

<display:table id="table1">
    <display:column title="Edit">
        <a href="#" onclick="sendData('${table1.emp_Name}')">Edit</a>
    </display:column>
</display:table>
Parth Patel
  • 799
  • 1
  • 13
  • 20