I use SmartGWT 3.0 Power.
I have a ListGrid with about 50.000 records. After filtering and clicking a button, I want to update the records in the database (change field 'isActive' from '1' to '0').
This works for "some" (e.g. 20 selected records). However, it does not work for 100s or 1000s of selected records.
I already activated dataRecordTable.setDataFetchMode(FetchMode.BASIC); to load ALL data. So that is not the problem I think.
Of course the code was not efficient for 1000s of records (I was just calling updateData(record); for every single record in a for-loop). Probably, this is why it crashes.
I do NOT have any DMI class for this datasource yet. I do not need it because I just want to do a simple update of a field. I need some kind of batching, i.e. just one HTTP request.
After looking at the SmartGWT Quick Start Guide, I think I have to use RPCManager.startQueue and .sendQueue on client-side (as shown in the example below), right? Unfortunately, documentation is very short about this topic.
Anyway, it does not work for me. The application freezes after some seconds and nothing is happening. I have to refresh the browser to restart the app. Database content did not change either.
What is wrong with my code? Do I need to write a server-side DMI class or anything else?
(again: the code works, but just for "some" records, so I think it is still doing one HTTP request for each record instead of batching / queuing?)
Here is the code:
An additional question is, if I can solve this WITHOUT dataRecordTable.setDataFetchMode(FetchMode.BASIC); ??? I do not want to load all data at the beginning.
Thanks for help...
I have a ListGrid with about 50.000 records. After filtering and clicking a button, I want to update the records in the database (change field 'isActive' from '1' to '0').
This works for "some" (e.g. 20 selected records). However, it does not work for 100s or 1000s of selected records.
I already activated dataRecordTable.setDataFetchMode(FetchMode.BASIC); to load ALL data. So that is not the problem I think.
Of course the code was not efficient for 1000s of records (I was just calling updateData(record); for every single record in a for-loop). Probably, this is why it crashes.
I do NOT have any DMI class for this datasource yet. I do not need it because I just want to do a simple update of a field. I need some kind of batching, i.e. just one HTTP request.
After looking at the SmartGWT Quick Start Guide, I think I have to use RPCManager.startQueue and .sendQueue on client-side (as shown in the example below), right? Unfortunately, documentation is very short about this topic.
Anyway, it does not work for me. The application freezes after some seconds and nothing is happening. I have to refresh the browser to restart the app. Database content did not change either.
What is wrong with my code? Do I need to write a server-side DMI class or anything else?
(again: the code works, but just for "some" records, so I think it is still doing one HTTP request for each record instead of batching / queuing?)
Here is the code:
Code:
deactivateFilteredImportsButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final Record[] selectedRecords = dataRecordTable.getRecords(); int size = selectedRecords.length; if (size > 0) { SC.ask("Deactivate filtered imports (i.e. all records you see at the moment)?", new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { RPCManager.startQueue(); for (int i=0; i<selectedRecords.length; i++) { Record record = (Record) selectedRecords[i]; record.setAttribute(COLS.workloadActive, 0); AppController.WORKLOAD.updateData(record); } RPCManager.sendQueue(); } } }); } else { SC.warn("No imports selected for deactivation"); } } });
Thanks for help...
Comment