Page 2 of 2
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 9:20 am
by selector
kev1n wrote: ↑Mon Mar 28, 2022 9:11 am
Try calling nuSubformHideColumns() just ones, by passing all columns to hide. Subsequent calls might be causing that issue.
Code: Select all
let dstr = nuGetValue("mt_date") + ".01";
let d1 = new Date(dstr);
let days = 31 - new Date(d1.getFullYear(), d1.getMonth() + 1, 0).getDate();
nuSubformHideColumns("mt_items",["tmi_val_31","tmi_31"]);
//for (let i=1; i<= days; i++)
// {
// nuSubformHideColumns("mt_items",["tmi_" + String(32-i),"tmi_val_" + String(32-i) ]);
// }
Before
111.png
After
222.png
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 9:25 am
by selector
kev1n wrote: ↑Mon Mar 28, 2022 9:17 am
The sf values are in .rows
I want to get the original object value from the main form. For such an object, the rows array is empty.
333.png
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 9:46 am
by kev1n
I assumed you'd like to get the subform's original values.
Use nuRemoveFormatting() to get an object's unformatted value:
Code: Select all
$('#mt_date').nuRemoveFormatting()
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 10:00 am
by selector
kev1n wrote: ↑Mon Mar 28, 2022 9:46 am
I assumed you'd like to get the subform's original values.
Use nuRemoveFormatting() to get an object's unformatted value:
Code: Select all
$('#mt_date').nuRemoveFormatting()

this is it. Thank you. Thanks to this, I deleted two extra lines of code. It remains to understand what to do with the columns in the subform and with the width of the subform itself. Is it possible to automatically change the width of the subform to the size of the browser?
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 10:12 am
by kev1n
The modified nuSubformRearrangeColumns() seems to work better when the subform has a horizontal scrollbar.
Replace the existing function in nuform.js, then log in again.
Code: Select all
function nuSubformRearrangeColumns(sf, fields, row, maintainWidth) {
function obj(p) {
return $("[id$='" + p + "']")
}
let width = 3;
let widthSf = $('#' + sf).cssNumber('width');
let widthScrollDiv = $('#' + sf + 'scrollDiv').cssNumber('width');
let widthHiddenColumns = 0;
if (row !== '') row = nuPad3(row);
nuHide(sf);
for (let i = 1; i < fields.length; i++) {
let p = row + fields[i][0];
let p0 = '000' + fields[i][0];
if (fields[i][1] == '0') {
let h0 = obj(p0);
if (! h0.is('[nu-subform-column-hidden]')) {
h0.attr('nu-subform-column-hidden','');
let h = obj(p);
widthHiddenColumns += h.cssNumber('width');
h.nuHide();
}
} else {
if (obj(p0).attr('data-nu-type') == 'lookup') {
obj(p + 'code').css('left', width);
width = obj('code').cssNumber('width') + width + 6;
obj(p + 'button').css('left', width);
width += 19;
obj(p + 'description').css('left', width);
width = obj('description').cssNumber('width') + width + 6;
} else {
obj(p).css('left', width);
width = obj(p0).cssNumber('width') + width + 6;
}
}
}
if (maintainWidth !== false) {
$('#' + sf + 'scrollDiv').css('width', widthScrollDiv - widthHiddenColumns);
$('#' + sf + 'nuTabHolder').css('width', widthScrollDiv - widthHiddenColumns);
if (widthSf > widthScrollDiv) {
$('#' + sf).css('width', widthSf - widthHiddenColumns);
}
}
nuShow(sf);
}
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 10:50 am
by selector
kev1n wrote: ↑Mon Mar 28, 2022 10:12 am
The modified nuSubformRearrangeColumns() seems to work better when the subform has a horizontal scrollbar.
Replace the existing function in nuform.js, then log in again.
Scrollbars we have won. ))) But there are small artifacts. For example, the delete column disappeared. And the first 3 fields in the subform have the lookup type. Two of them have an active description. These fields were crawling over each other. There is also a small incomprehensible piece of the title.
Before
111.png
222.png
After
333.png
444.png
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 11:12 am
by kev1n
It would probably be easier to just disable the columns instead of hiding. You can also try to fix nuSubformRearrangeColumns() yourself as I don't have much time at the moment.
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 3:46 pm
by selector
kev1n wrote: ↑Mon Mar 28, 2022 11:12 am
It would probably be easier to just disable the columns instead of hiding. You can also try to fix nuSubformRearrangeColumns() yourself as I don't have much time at the moment.
I found the error and fixed it, but there is a problem in the presence of "magic numbers" in the code. Such as +6 and so on. Because of this, the intervals between the fields are different and there are still minor problems with rendering. Could you tell me what the procedure for the initial rendering of subform fields is called? It is necessary to bring the margins to uniform numbers.
Re: hide(show) subform columns(objects)
Posted: Mon Mar 28, 2022 3:51 pm
by kev1n
See nuform.js, function nuBuildEditObjects()