首先,我想提一下,我正在使用angular2和jqxgrid。
我有jqxgrid,显示动态数据并正常工作。但是当我尝试刷新网格或尝试重新绑定它时,网格会显示第一次加载的数据,而不是刷新数据。
我在jqxgrid中显示数据的代码如下:
let url = "http://xxxx" + parameter1 + "xxxx" + parameter2;
let sourceGrid =
{
datatype: "json",
datafields: [{ "name": "name", "type": "string" },...],
url: url
};
let dataAdapter = new $.jqx.dataAdapter(sourceGrid, {
downloadComplete: (data, status, xhr) => { },
loadComplete: data => { },
loadError: (xhr, status, error) => { }
});
this.settings = {
width: 1500,
source: dataAdapter,
....,
columns:[{ "text": "name", "datafield": "name"},...]
}
this.myGrid.createWidget(this.settings);
到目前为止,一切正常。在按钮的单击事件中,我通过传递参数得到数据,即新数据来自dataAdapter,但jqxgrid不重新绑定或刷新新数据。到目前为止,我已经尝试过:
...
dataAdapter.dataBind();
this.myGrid.source = sourceGrid;
this.myGrid.updatebounddata();
...
我使用dataAdapter绑定获取了新数据,但jqxGrid仍然显示旧数据。我已经尝试过refreshData(),refresh(),尝试使用新的适配器,但网格是刷新的。不确定序列。
有人可以通过快速解决方案帮助我吗?
答案 0 :(得分:1)
我得到了一个用动态数据刷新网格的解决方案:
private function eActivate(e: Event):void
{
// app has opened or resumed
trace("state eActivate");
naApplication.removeEventListener(Event.ACTIVATE, eActivate);
naApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}
private function eDeactivate(e: Event):void
{
// app is going to be moved to background
// --- Pause Game Code ---
//
naApplication.removeEventListener(Event.DEACTIVATE, eDeactivate);
naApplication.systemIdleMode = SystemIdleMode.NORMAL;
}
private function eExiting(e: Event):void
{
trace("state eExiting");
// app is going to be closed by user or by the OS (usually to free up memory)
// do whatever exit code here then remove all listeners (to be clean don't rely on OS to close them)
naApplication.removeEventListener(Event.ACTIVATE, eActivate);
naApplication.removeEventListener(Event.DEACTIVATE, eDeactivate);
naApplication.removeEventListener(Event.EXITING, eExiting);
naApplication.systemIdleMode = SystemIdleMode.NORMAL;
// removeEventListener(Event.ENTER_FRAME, eMainTimer);
}
感谢jQWidgets团队