css for tableview with unselected records

Questions and answers for designing and implementing forms in Servoy

css for tableview with unselected records

Postby tgs » Fri Jul 20, 2012 5:32 pm

Is there a way in the style sheet to get a tableview form onShow or if loaded without the background-color and font-color for selected, but with it if I click on a row for selecting a record?
I mean if I load/show first time a tableview list nothing should be highlighted as selected. First I select a record manually (or by function) it should be displayed as selected.

Servoy 6.0.7
Java 1.6.0_33


Regards,
Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 886
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: css for tableview with unselected records

Postby achiary » Thu Jul 26, 2012 1:14 am

Try changing colors in onRender event .
achiary
 
Posts: 83
Joined: Wed Nov 14, 2007 3:29 pm
Location: Argentina

Re: css for tableview with unselected records

Postby mskv1309 » Thu Aug 09, 2012 10:05 pm

I am facing same problem.

I have onRender(), by defualt first record gets selected that is background color of frist record changes in tableview. I want record should get selected(change the background color) only once user selects the row. Below is the code snippet for onRender().

function onRender(event) {
if (event.isRecordSelected()) {
event.getRenderable().fgcolor = '#3566D5';
}
}

Is there any way we can change the color of record only when user selects the record. Any suggestion is appreciated.
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm

Re: css for tableview with unselected records

Postby djlapin » Tue Aug 14, 2012 12:32 am

I have wondered about this, also. Someone informed me that it is because the cursor (pointer?) is always on a record in an SQL table.

Don
djlapin
 
Posts: 309
Joined: Fri Feb 18, 2011 9:36 am
Location: San Francisco, CA

Re: css for tableview with unselected records

Postby mskv1309 » Tue Aug 14, 2012 4:51 pm

Thanks Don,
Yes exactly, by default pointer points to first record in foundset whether selected or not. Still is there any solution to highlight entire record in table view only when user selects the record.

Any one has any solution let us know. That would be a great help.

I am thinking to add a dummy record and load all the records along with other required records in table and hide dummy record at runtime and set some flag to that record so that OnRender() highlights dummy record. But I don't know how to hide entire record in foundset/table view. Does any know how to hide record in table view/foundest. That will be appreciated.
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm

Re: css for tableview with unselected records

Postby david » Tue Aug 14, 2012 5:49 pm

mskv1309 wrote:Any one has any solution let us know. That would be a great help.

I am thinking to add a dummy record and load all the records along with other required records in table and hide dummy record at runtime and set some flag to that record so that OnRender() highlights dummy record. But I don't know how to hide entire record in foundset/table view. Does any know how to hide record in table view/foundest. That will be appreciated.


We've tried a bunch of things and it is currently not possible to do without a lot of work.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: css for tableview with unselected records

Postby mskv1309 » Tue Aug 14, 2012 5:54 pm

Thanks David,

Ok. May I know in brief how is it possible to accomplish. Is it through javascript or can we do in HTML, how can we do. I would like to know, if possible.
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm

Re: css for tableview with unselected records

Postby david » Tue Aug 14, 2012 6:01 pm

Web client only solution. Involves a bunch of post rendering client-side javascript.

onRender() won't help you at all. It fires a number of times per table view so almost impossible to write code in it that targets a particular record beyond selected, even and odd.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: css for tableview with unselected records

Postby david » Tue Aug 14, 2012 6:02 pm

I would put in a feature request for something like forms.form_name.controller.setSelectedIndex = 0 removes record selection.
Last edited by david on Tue Aug 14, 2012 7:07 pm, edited 1 time in total.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: css for tableview with unselected records

Postby Harjo » Tue Aug 14, 2012 6:50 pm

+1
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: css for tableview with unselected records

Postby tgs » Wed Aug 15, 2012 12:06 am

+1
Thomas Schnaus
SAN Developer
yomotec GmbH
User avatar
tgs
 
Posts: 886
Joined: Wed Oct 04, 2006 12:05 pm
Location: Germany

Re: css for tableview with unselected records

Postby david » Wed Aug 15, 2012 7:24 am

Method names correspond to the form events of whatever table view you want this to work on. 20 second video of this in action here: http://www.youtube.com/watch?v=ZMtXLAIr6jI

Works great in web client -- a little dodgy in smart client as I didn't spend any time with it fine tuning. Still lodge a feature request with Servoy. One line of code as compared to all this....

The real value of this exercise for us was figuring out that code in the onRender event can be controlled above and beyond the standard event states via form variables. Might come in handy someday.

Code: Select all
/**
* Track last record index.
*
* @type {Number}
*
* @properties={typeid:35,uuid:"A59AE8F4-8C19-4E39-ACC9-B2DB24E1A2AB",variableType:4}
*/
var _index = null;

/**
* Track first show state of form.
*
* @type {Number}
*
* @properties={typeid:35,uuid:"C737D741-9579-4C6D-9A2A-3A25B5AE60D7",variableType:4}
*/
var _firstShow = null;

/**
* @properties={typeid:24,uuid:"B9BFB294-B3A8-4C12-A2E2-6C227BDC25AB"}
*/
function onShow(firstShow, event) {
   // if table in related form, onRecordSelection event of parent form should
   //       set these same form variables to same initial values
   _firstShow = 0
   _index = 1
}

/**
* @properties={typeid:24,uuid:"94ABDB15-1D59-47AA-BE2F-6392C3CE18A2"}
*/
function onElementFocusLost(event) {
   _index = controller.getSelectedIndex()
}

/**
* @properties={typeid:24,uuid:"13BA49DC-4B7D-45AF-913A-80ED8AD71E5B"}
*/
function onElementFocusedGained(event) {
   if ( !_firstShow ) {
      // setDesignMode() forces full UI redraw in web client so only do if
      //       if clicking same record
      if ( controller.getSelectedIndex() == _index ) {
         // hack to force onRender to fire when selecting a record that is already
         //       the current index
         //      (onRecordSelection event doesn't fire in this case...ergo, onRender doesn't fire)
         controller.setDesignMode(true)
         controller.setDesignMode(false)
      }
      _firstShow = 1
   }
}

/**
* @properties={typeid:24,uuid:"4F331175-1E08-415A-88B7-1BFD59D05D2D"}
*/
function onRender(event) {
   // event that overrides form css for selected
   //       only fire if first time (tracked in form variable: _firstShow)
   if ( !_firstShow && event.isRecordSelected() ) {
      event.getRenderable().bgcolor = '#ffffff' // non-selected color
   }
}
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.


Return to Forms

Who is online

Users browsing this forum: No registered users and 9 guests