tableview current selected behaviour in web

Yes another question on “how” to get the current selected record to be highlighted in a table view in a web client.

I created a simple form, set the view to tableview(locked), specified the typical rowBgColorCalculation and it displays ok in smart client. When launch the web client the rows are coloured correctly for all rows when the selected argument is false. The selected argument never seems to be true and therefore the current selected record is not highlighted.

Is there another step I have missed to set up the current selected record - for example via the onShow method by setting the row index to the first one?

(I did put a test in the rowBgColorCalculation such that if ever it entered that conditional code it would change a label to something else - but it seems not to enter that code).

Hi Tom

As you have discovered, at present the selected row cannot be highlighted using rowBGcolor in WebClient.

One alternative is to set a global field when a row is selected and use this in an unstored calculated field that displays an Image to show users the current row.

var vCalc = null
if(zzid_patient == globals.curr_PatientID)
{
	vCalc = '<html><img border=0 src="media:///icon_arrow_down.gif"></html>'
}
return vCalc;

HTH

Thanks for the tip. It does work as you say.

However, if I now introduce a button to advance the row or decrease the row I have to know when I get to the end of the displayable table area (last row) and somehow invoke a goto next page (and the reverse when reaching the top and needing to go to the previous page and handle the end of table and the start of table).

I had thought the Servoy provided web client was a little smarter than this behaviour. It seems to me way to much work to have to do it this way when it might be done automatically.

Is it not possible to code this?

You know how many rows are displayed and can keep track of which row has been selected so may be possible to setSelectedRecord for the next one. Haven’t tried this but would be interested to know how you get on.

grahamg:
Hi Tom

As you have discovered, at present the selected row cannot be highlighted using rowBGcolor in WebClient.

One alternative is to set a global field when a row is selected and use this in an unstored calculated field that displays an Image to show users the current row.

var vCalc = null

if(zzid_patient == globals.curr_PatientID)
{
vCalc = ‘
}
return vCalc;




HTH

As an alternative, if you don’t want the icon, but prefer to mimic the row highliting, you can avoid the extra calc and place your calc into the rowBGcalculation. Something like:

var index = arguments[0];
var selected = arguments[1];
if (selected || zzid_patient == globals.curr_PatientID){
   return "#b5d5ff";
}
else{
   if (index % 2 == 0)//alternate even/odd
   {
      return '#ffffff';
   }else{
      return '#ffffcc'//'#f1eded' '#d7eff5';
   }
}

Ric,
I did put code in the rowBgColorCalculation method that sets a colour to highlight the selected record and to a different colour for the non selected. The problem is as I said in a previous email that the selected condition is NEVER satisfied - i.e. the code never enters that section. This must be because the web version does not do something correctly or it is disabled (crippled?). The smart client version works correctly.

I was hoping that I could have the smart client and the web client look and feel identical. Now I find something is broken or I am not doing something to force the javascript to generate a selected record event.

Tom Parry:
Ric,
I did put code in the rowBgColorCalculation method that sets a colour to highlight the selected record and to a different colour for the non selected. The problem is as I said in a previous email that the selected condition is NEVER satisfied - i.e. the code never enters that section. This must be because the web version does not do something correctly or it is disabled (crippled?). The smart client version works correctly.

You definitely need a way to select the record, in order to set a value to the global field, as Graham suggested. In most cases, a table view leads to a detail view (often a formindialog), so triggering the event when you click on a “show details” icon (or the line itself) could be an easy way to accomplish that task.

Otherwise, if you need to highlight the currently selected record with no user interaction at all, you probably need to deal with form events or similar techniques.

What I do not understand is the difference in the way a tableview behaves in the web client vs the smart client.

In the smart client the table is presented and the first record in the table (the top one of the first page). In the rowBgColorCalculation method the selected argument is “true” and the conditional code is entered which sets the colour to my highlight colour. For all the other rows the rowBgColorCalculation has the selected argument as false and the else part of my conditional block is entered which sets the row colour to some other colour than the high lighted colour. This is what I expected.

IN the web client only the else part of the conditional is entered (because the selected argument is false) therefore the row colour is set to the non-highlight colour (as I expected). The selected argument NEVER becomes true in the web client.

If this is the expected behaviour then please please put it in the documentation.

If, however, one has to programmatically set the selected record to the first one on the first page - how does one do that (e.g. during onShow event?).

I tried an experiment where I have a button in a footer area that gets the current selected record index, increments it and then sets the current selected record to this new value. I also have the icon showing the current record (as in the tip in a previous email). When in the web client I click on this I do get the icon to move to the next row, starting with the first row of the first page. However the selected argument never gets set true when the rowBgColorCalculation is called (BTW is there a way to debug a calculation as in single step?).

IN conclusion, it appears that I should set the “selected” row in web client to a highlight colour within the same method that I use to show the icon because there is no other way in the web client. Is this the way the web client should behave? Or is it this way due to a defect? (Sorry, that should read unimplemented feature ).

I think that what I want to do is to show the current selected record as if it were the same as the smart client “selected” behaviour. And know I need to know how to programmatically go to the next page when I move the current row icon down one past the page limit! (It never ends…). :wink:

Tom,

Perhaps you should post a feature request at:

http://forum.servoy.com/viewtopic.php?t=6361

Dean