Insert Element between Inline Fields

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
User avatar
fbrano
Veteran Member
Posts:73
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Insert Element between Inline Fields

Post by fbrano » 2025-10-10 17:09

Is it possible to insert custom text between Inline Fields. According description "P x D = Riziko" I'd like to insert "x" and "=".

Code: Select all

new AppGiniField("Dopad_popis")
.insertAfter()
.alert("Pravdepodobnost: <b>1</b> = Nestalo sa v sektore, <b>2</b> = Stalo sa v sektore,  <b>3</b> = Stalo sa / Môže nastať u PZS, <b>4</b> = 1 krát za 3 roky u PZS, <b>5</b> = 1 a viac krát za rok u PZS", Variation.info);
new AppGiniFields(["Pravdepodobnost", "Dopad_hodnota", "Riziko"]).inline("P x D = Riziko");
new AppGiniField("Riziko")
.insertAfter()
.alert("PPO / DPO = Pravdepodobnost / Dopad po aplikovani opatrenia", Variation.info);
new AppGiniFields(["PPO", "DPO", "ZR"]).inline("PPO x DPO = Zostatkove Riziko");
Attachments
Insert-text-between-inline-fields.jpg
Insert-text-between-inline-fields.jpg (51.93 KiB) Viewed 6362 times
Best regards,
Brano

AppGini 26.12 + AppGini Helper + Mass update + Summary reports + Search page maker

My NIS2 governance risk compliance platform https://emanazerkb.sk

saymaad
AppGini Super Hero
AppGini Super Hero
Posts:131
Joined: 2024-06-03 16:17

Re: Insert Element between Inline Fields

Post by saymaad » 2025-10-13 13:25

It is possible to manipulate the interface whatever way you want using jQuery that is included as part of AppGini.
Have you tried anything yourself? is the screenshot a mockup of what your desired view should look like?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts:2027
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Insert Element between Inline Fields

Post by jsetzer » 2025-10-15 07:41

Is it possible to insert custom text between Inline Fields?
.inline() function (https://www.appgini.de/docs/Javascript- ... nline.html) does not provide any parameters for inserting custom text/html in between input-controls.

You may consider AppGiniHelper Multi Column Layout (https://www.appgini.de/docs/Javascript- ... ayout.html):

Code: Select all

AppGiniHelper.dv.createLayout([6, 6])
    .add(1, ["fieldname_1", "fieldname_2"])
    .add(2, ["fieldname_3", "fieldname_4"]);
This will create a row of two columns, 50% width, each (6/12 = 50%). Column 1 will contain fields fieldname_1 and fieldname_2. Column 2 will contain fields fieldname_3 and fieldname_4.

If you want just one row and one field per column:

Code: Select all

AppGiniHelper.dv.createLayout([6, 6])
    .add(1, ["fieldname_1"])
    .add(2, ["fieldname_2"]);
If you need more than two columns, just change the array [6,6] to something different, for example [6,4,2]. Widths should sum up to 12 due to Bootstrap's 12-column-grid-system.

---

You may then use the label('...') function for re-labeling your field caption to 'x', for example

Code: Select all

AppGiniHelper.dv.getField("fieldname_2").label("x");
Label function:
https://www.appgini.de/docs/Javascript- ... ml?h=label


I know this can be done better using bootstrap's input-groups, but for now this is the only built-in, low-code option.
As @saymaad already mentioned, you can always use jQuery to customize every field individually.
Kind regards,
Jan <js />

AppGini 26.12 + all AppGini Helper tools

My Side Project
www.office-app.com | Coding Sample | Changelog | Blog | Top 20 Features
Integrated Statemachine Workflow • KANBAN • Audit Trail • Integrated API • Model Driven • Field-Level permission • Modern UI

My Company Website
www.bizzworxx.de

My AppGini Blog
appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability Image

User avatar
fbrano
Veteran Member
Posts:73
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: Insert Element between Inline Fields

Post by fbrano » 2025-10-15 12:26

// Does not work because of lookup type of fields "Pravdepodobnost" "Dopad_hodnota" "PPO" "DPO", while fields "Riziko" and "ZR" are read-only typ.

Code: Select all

// file: hooks/RA-dv.js
var dv = AppGiniHelper.DV;

dv.addTab("tab1", "Scenar rizika", "fire", ["ID", "System", "Ciel", "Zranitelnost", "OpZ", "Hrozba", "OpH", "Riesenie"]);
dv.addTab("tab2", "Vypocet", "remove", ["Apl", "PNH", "Dopad_popis","Pravdepodobnost", "Dopad_hodnota", "Riziko", "PPO", "DPO", "ZR"]);
dv.addTab("tab3", "Rozhodnutie", "eye-open", ["Rozhodnutie", "Poznamka", "Vlastnik", "Revidoval", "Datum_revizie"]);
dv.addTab("tab4", "Zaznam", "pencil", ["Zmenil", "Datum_zmeny"]);

//https://appgini.bizzworxx.de/products/javascript-library/documentation/detail-view/units-append-or-prepend/
dv.ready(function(){
 new AppGiniField("Riziko").prepend(" = Riziko ");
// Does not work because of lookup type of field
// new AppGiniField("Pravdepodobnost").append(" x ");
 new AppGiniField("ZR").prepend(" = Zostatkove Riziko ");
// Does not work because of lookup type of field
// new AppGiniField("PPO").append(" x ");
 new AppGiniField("Apl").append(" % aplikovaných požiadaviev podľa Posúdenia zhody (SoA)");
 new AppGiniField("PNH").append(" pravdepodobnosť z registra hrozieb");
});

//https://appgini.bizzworxx.de/products/javascript-library/documentation/detail-view/inline-fields/
new AppGiniField("Dopad_popis")
.insertAfter()
.alert("Pravdepodobnost: <b>1</b> = Nestalo sa v sektore, <b>2</b> = Stalo sa v sektore,  <b>3</b> = Stalo sa / Môže nastať u PZS, <b>4</b> = 1 krát za 3 roky u PZS, <b>5</b> = 1 a viac krát za rok u PZS", Variation.info);
new AppGiniFields(["Pravdepodobnost", "Dopad_hodnota", "Riziko"]).inline("P x D");
new AppGiniField("Riziko")
.insertAfter()
.alert("PPO / DPO = Pravdepodobnost / Dopad po opatreni", Variation.info);
new AppGiniFields(["PPO"," x ","DPO", "ZR"]).inline("PPO x DPO");
And here is my real detail view picture:
Attachments
Real-DV.jpg
Real-DV.jpg (44.42 KiB) Viewed 6286 times
Best regards,
Brano

AppGini 26.12 + AppGini Helper + Mass update + Summary reports + Search page maker

My NIS2 governance risk compliance platform https://emanazerkb.sk

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts:2027
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Insert Element between Inline Fields

Post by jsetzer » 2025-10-15 12:55

So, as @saymaad already mentioned, you should use jQuery for specific layout changes.

If I remember right, you can always get the DOM-element handle by calling .getElement() on a AppGiniHelper-field

Code: Select all

const e = AppGiniHelper.dv.getField("my_fieldname_1").getElement();
console.log(e); // check console output
You should be able to use append, prepend etc. then and build your own dv-layouts.

For controls like lookup, remember they are lazy loaded and will not be available on $j(document).ready(()=>{}).
Kind regards,
Jan <js />

AppGini 26.12 + all AppGini Helper tools

My Side Project
www.office-app.com | Coding Sample | Changelog | Blog | Top 20 Features
Integrated Statemachine Workflow • KANBAN • Audit Trail • Integrated API • Model Driven • Field-Level permission • Modern UI

My Company Website
www.bizzworxx.de

My AppGini Blog
appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability Image

saymaad
AppGini Super Hero
AppGini Super Hero
Posts:131
Joined: 2024-06-03 16:17

Re: Insert Element between Inline Fields

Post by saymaad » 2025-10-22 05:36

I am sharing a working and tested code that can solve this challenge and help users gain experience on detaching and manipulating fields in their AppGini apps. Make sure that the code is part of a global hook if you want to access this function across the application, or else just paste it in your tablename-dv.js file. You can call this function to rearrange the UI, as an example:

arrangeThreeFields('PPO','DPO','ZR','x','=','P x D');

Main function needed for the above to work:

Code: Select all

/**
 * arrangeThreeFields(f1, f2, f3, op1, op2, newLabel, sizes)
 *
 * f1,f2,f3     : field names (strings) e.g. "quantity","price","total"
 * op1,op2      : operator labels (strings) e.g. "x", "="
 * newLabel     : optional string to replace the label text of the first field row
 * sizes        : optional object to override bootstrap column sizes:
 *                { f1:2, op1:1, f2:2, op2:1, f3:3 }  (must sum 12)
 *
 * Behavior:
 * - Creates a nested .row inside the first field's .col-lg-9 and places the three controls + operators
 * - Detaches and moves the original .col-lg-9 children so events/data remain intact
 * - Hides the full containers of the second and third fields (keeps DOM present for form submissions)
 * - Keeps label of first field (optionally replaces its text). Hides labels of f2 and f3.
 */
function arrangeThreeFields(f1, f2, f3, op1, op2, newLabel, sizes) {
  // sanitize prefix
  var prefix = (AppGini.currentTableName() || '').toString().replace(/%/g, '').trim();
  if(!prefix) return;

  // default sizes (must sum to 12)
  sizes = sizes || { f1:3, op1:1, f2:3, op2:1, f3:4 };

  var sel1 = '.' + prefix + '-' + f1;
  var sel2 = '.' + prefix + '-' + f2;
  var sel3 = '.' + prefix + '-' + f3;

  var $c1 = $j(sel1);
  var $c2 = $j(sel2);
  var $c3 = $j(sel3);

  if(!$c1.length) return;

  // find label and control columns
  var $label1 = $c1.find('label.control-label').first();
  var $ctrl1 = $c1.find('.col-lg-9').first();

  var $label2 = $c2.find('label.control-label').first();
  var $ctrl2 = $c2.find('.col-lg-9').first();

  var $label3 = $c3.find('label.control-label').first();
  var $ctrl3 = $c3.find('.col-lg-9').first();

  // optional: replace label text for first element (keep inner HTML structure like <span> or required mark)
  if(typeof newLabel === 'string' && newLabel.length) {
    // replace only textual node(s) while preserving other nodes
    $label1.contents().filter(function(){ return this.nodeType === 3; }).remove();
    $label1.prepend(document.createTextNode(newLabel + ' '));
  }

  // hide labels for field2 and field3
  if($label2.length) $label2.hide();
  if($label3.length) $label3.hide();

  // detach inner control contents to preserve events and data
  var $inner1 = $ctrl1.children().detach();
  var $inner2 = $ctrl2.length ? $ctrl2.children().detach() : $j();
  var $inner3 = $ctrl3.length ? $ctrl3.children().detach() : $j();

  // build nested row inside first control column
  $ctrl1.empty();
  var $nestedRow = $j('<div class="row arrange-3fields-row" />');

  // helper to create column wrappers and append content
  function mkCol(size, content) {
    var $d = $j('<div />').addClass('col-lg-' + (size||1));
    if(content) $d.append(content);
    return $d;
  }

  // create operator block (centered)
  function mkOp(size, txt) {
    var $d = mkCol(size, $j('<p class="form-control-static" style="text-align:center" />').text(txt));
    return $d;
  }

  // assemble columns in order: f1, op1, f2, op2, f3
  $nestedRow.append(mkCol(sizes.f1, $inner1));
  $nestedRow.append(mkOp(sizes.op1, op1));
  $nestedRow.append(mkCol(sizes.f2, $inner2));
  $nestedRow.append(mkOp(sizes.op2, op2));
  $nestedRow.append(mkCol(sizes.f3, $inner3));

  // append to first control area
  $ctrl1.append($nestedRow);

  // reduce/hide the other field containers so they don't show as full rows but remain in DOM for server processing
  $c2.hide();
  $c3.hide();

}


Post Reply