Setting the title dynamically in detail view

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
skoch
Veteran Member
Posts: 49
Joined: 2020-01-27 14:20

Re: Setting the title dynamically in detail view

Post by skoch » 2020-02-10 08:28

... shows the same result in the title bar at start:
"Flst. Nr. [object Object]"
Does not respond to a change in the lookup field.

If "text" is added to the getValue option, the function "updateTitle(baugrund)" is executed on the onChange.

Code: Select all

function updateTitleOnStart() {
    var baugrund = new AppGiniField("bauflstID").getValue(text);
    updateTitle(baugrund);
}

skoch
Veteran Member
Posts: 49
Joined: 2020-01-27 14:20

Re: Setting the title dynamically in detail view

Post by skoch » 2020-02-10 08:43

... shows the same result in the title bar at start:
"Flst. Nr. [object Object]"
Does not respond to a change in the lookup field.
If "text" is added to the getValue option, the function updateTitle (construction reason) is executed on onChange and when the data record is opened, "Baugrund?" displayed:

Code: Select all

function updateTitleOnStart() {
    var baugrund = new AppGiniField("bauflstID").getValue("text");
    updateTitle(baugrund);
}

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 08:46

please follow the original post:
viewtopic.php?f=13&t=3344&p=12130#p12130
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 08:49

You are right! To get the text of the selected lookup item using the .getValue() function you will have to pass true (or any other value which will be evaluated as "true", as you did in your code).

I have modified the example above and commented this.

Code: Select all

var lookup_value_text = new AppGiniField("LOOKUP_FIELDNAME").getValue(true);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 08:55

To get the text of the selected lookup item using the .getValue() function of AppGini Helper JavaScript Library you will have to pass an argument which evaluates to true.

Code: Select all

var lookup_value_text = new AppGiniField("LOOKUP_FIELDNAME").getValue(true);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

skoch
Veteran Member
Posts: 49
Joined: 2020-01-27 14:20

Re: Setting the title dynamically in detail view

Post by skoch » 2020-02-10 12:00

... despite the adjustment (true), only the output "Baugrund?" without field content is displayed via the "updateTitleOnStart" function.
The field contents are only displayed in the title when the lookup field is changed.

Best,
Stefan

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 12:24

Show us your code, please, otherwise I cannot help. Are there any errors in console?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

skoch
Veteran Member
Posts: 49
Joined: 2020-01-27 14:20

Re: Setting the title dynamically in detail view

Post by skoch » 2020-02-10 12:28

...this is the code:

Code: Select all

// setup change handler for lookup field
new AppGiniField("bauflstID").onChange(updateTitleOnChange);

// initially call the update function
updateTitleOnStart();

function updateTitleOnStart() {
    var baugrund = new AppGiniField("bauflstID").getValue(true);	
    updateTitle(baugrund);
}

function updateTitleOnChange(value) {
    var baugrund = value.text;
    updateTitle(baugrund);
}

function updateTitle(baugrund) {
    var text = baugrund ? "Flst. Nr. " + baugrund : "Baugrund?";
    new AppGiniDetailView().setTitle(text);	
}
[\code]
otherwise there is no code in the building site-dv.js

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 12:33

please remove the following code...
[\code]
otherwise there is no code in the building site-dv.js
...and try again
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 12:39

Here is an updated version which has been tested and works in a sample project in my environment:

Code: Select all

var my_fieldname = "patient_id";
new AppGiniDetailView().ready(updateTitleOnStart);
new AppGiniField(my_fieldname).onChange(updateTitleOnChange);

function updateTitleOnStart() {
    updateTitle(new AppGiniField(my_fieldname).getValue(true));
}

function updateTitleOnChange(value) {
    updateTitle(value.text);
}

function updateTitle(baugrund) {
    var text = baugrund ? "Flst. Nr. " + baugrund : "Baugrund?";
    new AppGiniDetailView().setTitle(text);	
}
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

skoch
Veteran Member
Posts: 49
Joined: 2020-01-27 14:20

Re: Setting the title dynamically in detail view

Post by skoch » 2020-02-10 12:48

Hey Jan,

your´re the best - now it works wonderful.
Thank you very very much :-))

Best,
Stefan

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-10 12:59

I'm glad and happy it works now! :D

Remember that these functions are still BETA and therefore yet undocumented and unsupported:
  • newAppGiniField(fieldname).getValue();
  • new AppGiniField(fieldname).onChange(callback);
  • new AppGiniDetailView().ready(callback);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-02-28 11:40

It this still open?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Setting the title dynamically in detail view

Post by SkayyHH » 2020-06-08 19:46

Hello,

this is nice.

Is this also possible with the table views? I have parent / child pages and would like to have a field name of the parent in the title.

Thanks much, Kai

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

Re: Setting the title dynamically in detail view

Post by jsetzer » 2020-06-11 06:08

Thanks for the idea.

Usually you can control the (plural) caption of the tables in your project.

But if you want to change it dynamically, you can use jquery:
Find the div.page-header. There is a <h1> inside which you can modify. It contains an <a> containing the image and the caption of the table.

There will be 4 new functions in next version of AppGini Helper Javascript Library:

Code: Select all

$j(document).ready(function () {
  var tv = new AppGiniTableView();
  // 1
  tv.setTitle("text");
  // 2
  tv.setTitleHtml("<b>Test</b>Test");
  // 3
  tv.addTitle(" for project " + project_name);
  // 4
  tv.addTitleHtml(" for project " + "<b>" + project_name + "</b>");
}
Result

1: text
2: TestTest

If table-caption is "Tasks" and project_name is "Project 1"
3: Tasks for project Project 1
4: Tasks for project Project 1

Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

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

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply