Here is the solution for making view_form with several images for each row. You have to:
1) create table with images indexed to corresponding row id's of the parent table (image field and reference field)
2) set view form option: uncheck all options in form tab and set only image field to be visible
2) put this code into .js file of the corresponding(parent) table (client_module)
3) change all occurrence images_table in code for your images table name and part_id for reference field to row id of the parent table in images table
4) as a result you will have images table instance in each row of the table view_form with corresponding images only and further you have to set css the way want the content to be displayed
I'm going to rework this for server-side solution. But still it's already usable. Feel free to mail me if you have questions.
function process_table_row(row, item) {
var id_l = item.id.value;
if (item.view_form.length) {
if (item.rec_count) {
var images_div = $("<div>", {
"class": "images", style:"overflow: hidden", id: id_l});
var images = $("<td>", {
"class": "images", style:"overflow: hidden"}).html(images_div);
row.find('td:visible:last').after(images);
}
}
task.images_table.paginate = false;
task.images_table = task.images_table.copy();
task.images_table.create_table(row.find('.images').last(), {
height: 200,
form_border: false,
});
task.images_table.set_where({part_id: id_l});
task.images_table.open(true);
var sub_tables = $("div.images_table table")
sub_tables.each(function(){
$(this).removeClass("table-bordered")
});
};
function on_view_form_created(item) {
item.table_options.row_callback = process_table_row;
}
пятница, 8 января 2021 г. в 10:49:59 UTC+3, R. T.: