Reputation: 853
I am trying to implement dojo dgrid in my existing jsp table. I tried the example give here, and it works, but the issue is I am using a table, and I want to generate my JSON data in a way that it stores in , so it's properly aligned. I also checked the GridFromHTML and it's test, but I couldn't understand how to generate the JSON data with tds.
Here is the table code:
<table id="grid">
<tr class="colhdg">
<th><fmt:message key="Sequence"/></th>
<th><fmt:message key="Description"/></th>
<th><fmt:message key="Due Date"/></th>
<th><fmt:message key="Action"/></th>
</tr>
<c:forEach var="rowItem" varStatus="lineInfo" items="${formBean.rowList}">
<%@ include file="/standardoddeven.jsp" %>
<tr class="<c:out value='${trClass}'/>">
<td>
<c:out value="${rowItem.instructionSequence}"/>
</td>
<td>
<c:out value="${rowItem.description}"/>
</td>
<td>
<fmt:formatDate value="${rowItem.dueDate}" pattern='<%=session.getAttribute("DATEFORMAT").toString()%>'/>
</td>
<td>
<bean:define name="rowItem" id="submitObject" type="instructions" />
<c:if test="${formBean.allowedOptions.UiTaskInstructionsViewUpdateAllowed}" >
<%@ include file="/standardupdatedeletebuttons.jsp" %>
</c:if>
</td>
</tr>
</c:forEach>
EDIT1:
Wrote the code that works apart from the 'Update' button. Not sure how to add the last in jsp table code to the loop in javascript dojo.
Here is my code that works for the rest:
require([ 'dgrid/Grid', 'dojo/domReady!' ], function (Grid) {
var data = [
<c:forEach var="rowItem" varStatus="lineInfo" items="${formBean.rowList}">
{ sequence: '${rowItem.instructionSequence}', description: '${rowItem.description}', dueDate: '<fmt:formatDate value="${rowItem.dueDate}" pattern='<%=session.getAttribute("DATEFORMAT").toString()%>'/>', update: 'Update' }${!lineInfo.last ? ',' : ''}
</c:forEach>
];
var grid = new Grid({
columns: {
sequence: 'Sequence',
description: 'Description',
dueDate: 'Due Date',
update: 'Update'
}
}, 'grid');
grid.renderArray(data);
});
Upvotes: 1
Views: 136