When i have more that 10 dictionaries added to CSWeb 8.0.0, I cannot delete the latest dictionaries that are in a position after the top 10, but i can delete the first ones.
Reorder dictionaries or change the visible rows of the table do not help.
When i click the trash item, inside the dictionaries rows that i can not delete, the popup dialog is not displayed. So, this is not a problem in the php side. It should be a problem in the javascript side.
Thanks in advance.
CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
Thanks for the report. It will be fixed in the next release. Let me know if you need a workaround in the meantime.
Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
Well thanks. I can not find a workaround for this yet.
I think that the problem is in data.twig file, and is because of that:
$(".delete-button-class").on("click", function (event) {
The Datatablet create and removed the internal elements when you change the page. So, you really only connect the items that are visible when the page is loaded to that event. You need to be connected to the datatable change event instead or connect the click in some element at the top. For example:
$(".dictionary-data-table").on("click", function (event) {
And then find the real row that was clicked.
The problem is that modify the data.twig don't change the resulted rendered page. I'm missing something. How can i really change the resulted rendered page?
If you have already a workaround, please sendme the file that i need to change.
Thanks again!!
I think that the problem is in data.twig file, and is because of that:
$(".delete-button-class").on("click", function (event) {
The Datatablet create and removed the internal elements when you change the page. So, you really only connect the items that are visible when the page is loaded to that event. You need to be connected to the datatable change event instead or connect the click in some element at the top. For example:
$(".dictionary-data-table").on("click", function (event) {
And then find the real row that was clicked.
The problem is that modify the data.twig don't change the resulted rendered page. I'm missing something. How can i really change the resulted rendered page?
If you have already a workaround, please sendme the file that i need to change.
Thanks again!!
Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
I have fixed the problem with this code, that is the more efficient way to fix that (you don' t overload the page with a lot of event listener):
The missing thing was that i need to delete the twig cache (I never worked with twig before).
Please note that there are another issue more. The problem is when you have x+1 elements in the datatable and you paginate the datatable at x elements. In this case when you delete the x+1 element, the empty page remain there and is not removed. That is a little difficult to be fixed, because you need to take on account that you are using a datatable not an html table. That means refresh the datatable after remove the row element:
https://stackoverflow.com/questions/185 ... emove-done
So, instead of:
Should be:
Code: Select all
$("#dictionary-data-table").on("click", function (event) {
if ($(event.target).hasClass('delete-button-class') || $(event.target).closest(".delete-button-class").length) {
tr = $(event.target).closest("tr");
var dictionaryName = $(tr).data("dictname");
var dictionaryLabel = $(tr).data("dictlabel");
var modalText = 'Do you want to delete the "' + dictionaryLabel + ' (' + dictionaryName + ')" dictionary, or the data in it?';
$("#delete-modal").find('.modal-body').text(modalText);
$("#delete-modal").modal("show");
}
});
Please note that there are another issue more. The problem is when you have x+1 elements in the datatable and you paginate the datatable at x elements. In this case when you delete the x+1 element, the empty page remain there and is not removed. That is a little difficult to be fixed, because you need to take on account that you are using a datatable not an html table. That means refresh the datatable after remove the row element:
https://stackoverflow.com/questions/185 ... emove-done
So, instead of:
Code: Select all
$(tr).remove();
Code: Select all
var dt = $("#dictionary-data-table").DataTable();
dt.row($(tr)).remove().draw();
Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
Your observation is correct. Sorry for the inconvenience. We fixed the issue now and will publish it in our next release. The page redraw fix was addressed with this fix.
Code: Select all
const dataTable = $('#dictionary-data-table').DataTable();
let currentPage = dataTable.page();
dataTable.row($(tr)).remove();
const newTotalPages = dataTable.page.info().pages;
currentPage = currentPage !== 0 && currentPage >= newTotalPages ? newTotalPages -1 : currentPage ;
dataTable.page(currentPage).draw('page');
Re: CSWeb: Cannot delete a dictionary when we have more than 10 dictionaries.
Oh no, thanks for all your work done and for shared your software witch the rest of us. It would be perfect if CSPro were free software and made with free software (we can also help more that way), but at least CSWeb is free software. So. I'm happy to help a little.