私のJSPページには、多くの詳細を入力するフォームがあります。ユーザーが送信をクリックすると、フォームの下のグリッドに結果をアイテムとして表示したいと考えています。
JSPスクリプトレットを使用して各詳細を取得し、それをslickgridに割り当てています。これを行うためのコードは次のとおりです
<script>
var grid;
dataView = new Slick.Data.DataView();
var columns = [
{id: "SlNo", name: "SlNo", field: "SlNo"},
{id: "ItemName", name: "ItemName", field: "ItemName"},
{id: "PartNo", name: "PartNo", field: "PartNo"},
{id: "BatchNo", name: "BatchNo", field: "BatchNo"},
{id: "UnitRate", name: "UnitRate", field: "UnitRate"},
{id: "Quantity", name: "Quantity", field: "Quantity"},
{id: "Discount", name: "Discount", field: "Discount"},
{id: "NetAmount", name: "NetAmount", field: "NetAmount"},
{id: "TaxRate", name: "TaxRate", field: "TaxRate"},
{id: "TaxAmount", name: "TaxAmount", field: "TaxAmount"},
{id: "TotalAmount", name: "TotalAmount", field: "TotalAmount"}
];
var options = {
enableCellNavigation: true,
enableColumnReorder: false
};
grid = new Slick.Grid("#myGrid", dataView, columns, options);
dataView.onRowCountChanged.subscribe(function (e, args) {
grid.updateRowCount();
grid.render();
});
dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});
$('#btnSubmit').click(function() {
var data = [];
var i=0;
<%ERPConnectionManager erpConn = (ERPConnectionManager) session.getAttribute("erpCon");
ConfirmFunction(request, erpConn);
ArrayList<SalesRecCdty> listSalesRec = (ArrayList<SalesRecCdty>) session.getAttribute("listval");
Iterator itrn = listSalesRec.iterator();
while (itrn.hasNext()) {
SalesRecCdty salesrec = (SalesRecCdty) itrn.next();
String itemName = salesrec.getCommName().toString();
String partNo = "";
String batchNo = salesrec.getBatchNo();
String unitRate = String.valueOf(salesrec.getUnitrate());
String quanity = String.valueOf(salesrec.getReqQty());
String discount = String.valueOf(salesrec.getDiscount());
String netAmount = String.valueOf(salesrec.getNetValue());
String taxRate = String.valueOf(salesrec.getTaxpercent());
String taxAmount = String.valueOf(salesrec.getTaxtotal());
String totAmount = String.valueOf(salesrec.getTotalvalue());
%>
data[i]={
SlNo: i+1,
ItemName:"<%= itemName%>",
PartNo:"<%= partNo%>",
BatchNo:"<%= batchNo%>",
UnitRate:"<%= unitRate%>",
Quantity:"<%= quanity%>",
Discount:"<%= discount%>",
NetAmount:"<%= netAmount%>",
TaxRate:"<%= taxRate%>",
TaxAmount:"<%= taxAmount%>",
TotalAmount:"<%= totAmount%>"
};
i++;
<%
}
%>
// grid = new Slick.Grid("#myGrid", data, columns, options);
dataView.beginUpdate();
dataView.setItems(data);
dataView.endUpdate();
});
e.preventDefault();
var ajaxdata = $('#cbobxOffice').val();
$.ajax({
cache: false,
success: function(data) {
}
});
</script>
データをデータ配列にフェッチできます..しかし、行がグリッドに表示されません。助けてください