when I use xml to load data, it loads post request almost every milliseconds. The below code is part of showing xml datas.
DocumentOrderGrid extends DataGrid.
If grid.load exists, dhtxml load the xml every seconds. No matter how I comment the function content.
[ grid.load(config.xml, function() {}); ] ← this part.
dhtmlx 5 make infinite loop now
http://localhost:8080/ROOT/documentContractEmployee/records?xml=xml%2Fdocument%2Fcontract%2FemployeeGrid.xml&from=2023-06-13&to=2023-07-13&kind=DC0005&connector=true&dhx_no_header=1&posStart=7&count=10&dhxr1689231495543=1
If I comment grid.load(), then it doesn’t work at all. both normal data and abnormal data
How can I fix this?
Controller
@RequestMapping(value = "records", method = { RequestMethod.GET })
@ResponseBody
final public RecordSet getRecords(
@RequestParam(value = "posStart", required = false, defaultValue = "0") int posStart, //
@RequestParam(value = "count", required = false, defaultValue = "50") int count, //
@RequestParam(value = "xml") String xmlUrl, //
@RequestParam Map<String, String> params, //
@AuthenticationPrincipal AccessedUser user) {
if(user.getErpId().equals("master"))
xmlUrl = "master/" + xmlUrl;
return onRecords(posStart, count, xmlUrl, params, user);
}
protected RecordSet onRecords(int posStart, int count, String xmlUrl, Map<String, String> params, IUser user) {
TABLE table;
try {
table = getTableClass().getDeclaredConstructor(String.class).newInstance("tb");
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException | ClassNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
JPAQuery query = new JPAQuery(em);
query.from(table);
QueryBuilder builder = getQueryBuilder(query, posStart, count);
builder.setResourcePathPrefix();
builder.putPath(table);
Object parentId = onBeforeBuildPath(builder, table, params, user);
builder.buildFromParams(params);
// System.out.println(posStart);
// System.out.println(count);
// System.out.println(xmlUrl);
// System.out.println(params);
//System.out.println(parentId);
// System.out.println(builder.getQuery());
return builder.buildRecordSetByXml(xmlUrl, parentId == null ? null : parentId);
}
js
function setupGrid(container, kind, key) {
console.log(container, kind,key);
if (key == undefined)
key = kind;
var range = getRange(days);
gridMap[key] = new DocumentOrderGrid();
gridMap[key].setRecordUrl('documentContractEmployee/records');
gridMap[key].setUpdateUrl('documentContractEmployee/update');
/* gridMap[key].initToolbar(container, {
iconsPath : "../img/18/",
xml : "../erp/xml/message/toolbar2.xml",
}); */
gridMap[key].initGrid(container, {
imageUrl : imageUrl,
xml : "xml/document/contract/employeeGrid.xml",
}).setKind(kind).setRange(range).setTitle(container.getText()).setKey(key);
DataGrid.prototype.initGrid = function(container, config, filterType) {
this.container = container;
if (this.enableUpdateTitle)
this.title = container.getText();
this.xmlUrl = config.xml;
var me = this;
if (filterType != undefined)
me.filterType = filterType;
var grid = container.attachGrid();
this.grid = grid;
grid.setImagePath(config.imageUrl);
grid.enableContextMenu(null);
this.onBeforeInitedGrid(grid, container);
grid.load(config.xml, function() {
//setupDefaultGrid(grid);
//for ( var i in me.numberFormats) {
// setNumberFormat(grid, me.numberFormats[i].format, me.numberFormats[i].columns);
//}
//if (me.kidsXmlFile != undefined) {
// grid.kidsXmlFile = me.kidsXmlFile + '?xml=' + encodeURIComponent(me.xmlUrl);
//}
//me.onInitedGrid(grid, container);
//me.onInitedGridEvent(grid, container);
});