Dynamic titleText in table view (reprise)

Questions and answers for designing and implementing forms in Servoy

Dynamic titleText in table view (reprise)

Postby djlapin » Tue Jul 10, 2012 7:36 am

Okay, I've read through what seem to be the recent discussions on this topic. But, being a neophyte, I still don't know how to work around the limitation of not being able to set titles at runtime.

My table view is in a tab panel and displays a roster (Mon-Fri x 4 weeks, for 20 columns, see attached pic). So the column headers need to show the correct dates when the user changes the starting date of the roster.

Is this somehow done by changing the titleText with a solution model call, then refreshing? What does the call look like.

Thank you,
Don
Attachments
titleText.png
titleText.png (91.39 KiB) Viewed 3747 times
djlapin
 
Posts: 309
Joined: Fri Feb 18, 2011 9:36 am
Location: San Francisco, CA

Re: Dynamic titleText in table view (reprise)

Postby ROCLASI » Tue Jul 10, 2012 1:21 pm

Hi Don,

Such a call would look like this:
Code: Select all
/**
* @param {String} formName
* @param {String} elementName
* @param {String} titleText
*/
function doSetColumnTitle(formName, elementName, titleText) {
    var _oForm = solutionModel.getForm(formName),
        _oField;
    if (!_oForm) {
        application.output("Can't get form object with name '" + formName + "'", LOGGINGLEVEL.ERROR);
        return;
    }
    _oField = _oForm.getField(elementName);
    if (!_oField) {
        application.output("Can't get field object with name '" + elementName + "'", LOGGINGLEVEL.ERROR);
        return;
    }
    _oField.titleText = titleText;
    forms[formName].controller.recreateUI();
}


Just pass the correct formname and elementname (element needs to have a name set) and the titletext.

Hope this helps
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Dynamic titleText in table view (reprise)

Postby djlapin » Tue Jul 10, 2012 8:38 pm

Thank you Robert! - Don
djlapin
 
Posts: 309
Joined: Fri Feb 18, 2011 9:36 am
Location: San Francisco, CA

Re: Dynamic titleText in table view (reprise)

Postby amcgilly » Fri May 09, 2014 6:16 pm

Here's another approach which worked for me, but may not be applicable in all situations: if you can get a calc to return the label you want, then put that calc in the titleText property in the form editor, and it will refresh in the table header dynamically.
Adrian McGilly
Servoy Developer

Image
amcgilly
 
Posts: 375
Joined: Fri Dec 09, 2005 12:03 am
Location: San Francisco, CA

Re: Dynamic titleText in table view (reprise)

Postby jasantana » Sun May 11, 2014 11:18 am

Also a form variable could work
Best regards,
Juan Antonio Santana Medina
jasantana@nephos-solutions.co.uk
Servoy MVP 2015
Servoy 6.x - Servoy 7.x - Servoy 8.x - MySQL - PostgreSQL - Visual Foxpro 9
User avatar
jasantana
 
Posts: 555
Joined: Tue Aug 10, 2010 11:40 am
Location: Leeds - West Yorkshire - United Kingdom


Return to Forms

Who is online

Users browsing this forum: No registered users and 5 guests

cron