-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #131: A mapper function to map the frontend columns data with backend. A new yadcf_data params. Some small improvements. #132
base: master
Are you sure you want to change the base?
Conversation
- new parameter yadcf_data is added to ColumnDT class This change is necessary as before when the search method is set as yadcf_select, yadcf_multiselect and yadcf_autocomplete then always yadcf data is being returned even when it is not required by the frontend as in some cases the data can be defined in the frontend and no need of data is required from the backend. This commit provides the yadcf_data params which can be set to False when we don't want the yadcf_data. - new private method _map_columns_with_params in DataTables class This change is necessary as before when in frontend columns are not in the same order or extra then compared to frontend, it results in the wrong data to be sent to the frontend from the server. This method will compare the ColumnsDT data with the params data and would map the correct column number in the frontend to the ColumnDT data. - other improvements yadcf_multi_select in search_methods.py have been imporved to handle null from the JavaScript. In DataTables class add_column method have been changed to with_entities method in the query object as add_column add a column or columns to the list of columns but with_entities replaces the select list with the current entities.
- Add 3 new helper methods 1) create_dt_params_with_mData This create params when the data source is set in the frontend 2) create_dt_params_with_mData_shuffled It does the same thing as above but changes the order in the frontend as compared to the backend. 3) create_dt_params_with_mData_with_extra_data It does the same thing as Pegase745#1 but adds an extra column in the params coming from the frontend. - New tests 1) test_with_yacdf_data_params in test_column_dt.py test the yacdf_data params 2) parametrize test_fields_mData in test_fields.py so the test could be done on different cases of params from frontend
Thanks for this, will take a look. |
@Pegase745, I propose to run black formatter first (see #133), then rebase this PR on to get a proper diff. @kartikeyas00 I don't fully understand what usecase this is solving. But then I haven't looked at this codebase in a while. If I recall correctly you can either use yadcf (or one of the other options) to
|
I can possibly come up with an example in the next couple of days. But |
@tdamsma @Pegase745 Any update on this? |
There are still a bunch of merge conflicts, making it really hard to see what the scope of the changes is. Can you resolve them and run black on your code to minimize the diff? |
Regarding this issue, I have come up with a
_map_columns_with_params
private method in DataTables class in datatables.py module. This method compares columns data with the parameters data and map the correct column number to the columns data. As a lot of times in frontend columns are not in the correct order as they are in the backend. Also there are cases when extra dummy columns are added in the frontend and they disturb the sequencing, thus the results coming from the backend.I am also proposing a new
ColumnDT
params which isyadcf_data
Why?
When the search method is set as yadcf_select, yadcf_multiselect and yadcf_autocomplete then always yadcf data object is being returned from the backend even when someone doesn't want it as in some cases the data can be defined in the frontend and no data is required from the backend.
For example: If a column contains only yearly data, then one can easily define the options in the frontend for yadcf and backend doesn't have to look at all the records in that column and retrieve the unique records as the option. It can also save server processing.
This PR provides the
yadcf_data
params forColumnDT
class which can be set toFalse
when we don't want the yadcf_data. It would be default toTrue
Other improvements proposed
yadcf_multi_select
method in search_methods.py module have been improved to handlenull
from the JavaScript.In
DataTables
classadd_columns
method have been replaced withwith_entities
method in the query object asadd_columns
method was adding a column or columns on the top of the list of columns who already exists in the table or query butwith_entities
replaces the select list with the current entities which means it would only have the columns selected with thewith_entities
clause.