Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Reposition a Maintain Grid on a desired row

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Reposition a Maintain Grid on a desired row
 Login/Join
 
Gold member
posted
I need to search a maintain grid for a desired record and, when found, reposition the grid to show that row. I have the following VBScript code as my search button event.

Sub OnButton1_Click ( )
IWCTrigger "Find_Detail", "RowN"
s9_Form.Grid1.SetCurrentRow s9_Form.TriggerValue
s9_Form.Grid1.RedrawAll
End Sub

Find_Detail finds the desired row and places it in RowN, but the grid always displays starting at row 1. Is my coding wrong or do I need to uses a different technique.

Kent


Windows2003 Server, WebFOCUS 7.7.02 Developers Studio and MRE
 
Posts: 63 | Location: Ft. Wayne, IN | Registered: February 20, 2007Report This Post
Virtuoso
posted Hide Post
Kent

I have never used the grid in real life (I need to have maintains run in Firefox), so I cannot answer directly as to how to achieve what you want.

However, the logic you are using looks problematic. The IWCTrigger passes control back to the maintain on the server. The lines in the script following that will not run, because when maintain passes control back to the user page, it is a new page and does not know that you were in the middle of a script; it starts totally afresh again.

If Find_Detail could populate a hidden input with a row number, perhaps you could attach a script to run an onload event that would then set the grid to the value taken from the hidden input.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Platinum Member
posted Hide Post
You should use javascript or vbscript to loop thought all cells. Within the loop, you get the value from the cell(or row) and compare, if the comparison satifies you, then you set focus to that cell.

As Alan mentioned, IWCTrigger is the way javascript talks to Maintain functions, which will not fulfil your goal.
 
Posts: 118 | Location: Omaha, NE | Registered: June 12, 2003Report This Post
Virtuoso
posted Hide Post
Kent

To put a bit more explanation on my previous response.

In your Sub OnButton1_Click event, just have the IWC_Trigger call.
Declare a variable called rowNumber/i4;
In Find_Detail, set rowNumber value to the row number that your search found.
Add an edit box onto your form, initial text to rowNumber, visible parameter to No and call it RowValue.
Create a js file and attach it to the form s9_Form.
In the js file have:
  
function showRow() {
var x=document.getElementById("RowValue").value;
s9_Form.Grid1.SetCurrentRow s9_Form(x);
s9_Form.Grid1.RedrawAll;
}
document.onload=showRow();


Note:
Changed window.onload to document.onload, as window.onload is causing an issue with maintain.

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
All
I realize that this doesn't add to the "Setting a Row in a Grid conversation", but I am adding this small doc on SetCancelFlag here. When a user tabs out of a cell, use SetCancelFlag after checking the validity of the data and to determine if the cursor needs to be returned to the cell. I will write this up in the next WebFOCUS Newsletter, but for now, it is all here.

Mark

The "OnEditFinish" Grid event, which is triggered when the user moves off a cell after an edit, can be used to control the value of the current cell by coding the SetCancelFlag function with different parameters:.
• When the parameter passed to this function is Zero (0) the application is unable to use the OnEditFinish event to restrict the contents of the current cell; any value is accepted from the user. This is the default setting.

• When the parameter passed to this function is One (1) the application is able to use the OnEditFinish event to prevent the user from entering an undesirable value for the current cell while allowing them to continue to try other values.
Example: if (text == "MAYBE")
{
Form1.Grid1.SetCancelFlag(1);
alert("Invalid value - please try again");
}

• When the parameter passed to this function is Two (2) the application is able to use the OnEditFinish event to prevent the user from entering an undesirable value for the current cell, and no further user action is allowed on the cell at that time. It can be used with CellSetText or QuickSetText to automatically change the contents of the current cell to a specific value, or else it will automatically revert to the original value.

Example: if (text == "MAYBE")
{
Form1.Grid1.SetCancelFlag(2);
Form1.Grid1.GetCell(col,row);
Form1.Grid1.CellSetText("NO");
Form1.Grid1.SetCell(col,row);
Form1.Grid1.RedrawCell(col,row);
alert("Invalid value - changing to NO");
}
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Virtuoso
posted Hide Post
Don't take this the wrong way or anything, but are you kidding me? This is the only way to move the grid from a Maintain trigger?

J.



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Virtuoso
posted Hide Post
John,

Not kidding at all, based on Kent's original approach. That's 5 lines of extra JS code, which in the world of JS is not exactly overload.

It could be done all in JS rather than reverting back to the server of course.

Remember that the grid is an ActiveX control and therefore cannot be accessed as easily by JS, as, say, an HTML table, and has it's own rules.

Just out of interest what approach would you like to see?


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
This works and does not return to the server to function. Note that my grid on the screen is 14 rows tall -- that's why there's all the futzing with 14 in the bottom half of the function.

function OnButtonFindSite_Click ( ) {
var GridLength = Counselor_List.Grid1.GetNumberRows();
var row = 0;
var found = false;
while (row < GridLength && found==false)
{
Counselor_List.Grid1.GetCell(0,row);
var CellValue=Counselor_List.Grid1.CellGetText();
if (Counselor_List.Grid1.CellGetText() == Counselor_List.EditRecordLookup.value)
{
found = true;
}
else row++;
}

if (found)
{
var NewGridPosition=row+14; // 14 moves desired record to top of the grid.
if (NewGridPosition < 14)
NewGridPosition=row; // Handles case where New Grid Position is on first page -- no offset needed.
if (NewGridPosition > GridLength)
NewGridPosition=GridLength; // Makes sure New Grid Position isn't bigger than the grid.
Counselor_List.Grid1.SetCurrentRow(0);
Counselor_List.Grid1.RedrawAll;
Counselor_List.Grid1.SetCurrentRow(NewGridPosition);
Counselor_List.Grid1.RedrawAll;
}
else
alert("That counselor number does not exist in the table.");
}



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
Gold member
posted Hide Post
Thank you John Edwards. Your coding was almost exactly what I needed.
Kent


Windows2003 Server, WebFOCUS 7.7.02 Developers Studio and MRE
 
Posts: 63 | Location: Ft. Wayne, IN | Registered: February 20, 2007Report This Post
Gold member
posted Hide Post
Can someone who knows JavaScript tell me how to change the following Grid search so it is case-insensitive:

function OnSearchButton_Click ( ) {
var GridLength = s9b_Perpetual_Billing.Grid1.GetNumberRows(); // JavaScript Code
var row = 0;
var found = false;
while (row < GridLength && found==false)
{
s9b_Perpetual_Billing.Grid1.GetCell(2,row);
var CellValue2=s9b_Perpetual_Billing.Grid1.CellGetText();
s9b_Perpetual_Billing.Grid1.GetCell(3,row);
var CellValue3 = s9b_Perpetual_Billing.Grid1.CellGetText();
var CellValue = (CellValue2 + CellValue3);
var Searchv = CellValue.search(s9b_Perpetual_Billing.SearchValue.value)
if (Searchv >= 0)
{
found = true;
}
else row++;
}

Thanks, Kent


Windows2003 Server, WebFOCUS 7.7.02 Developers Studio and MRE
 
Posts: 63 | Location: Ft. Wayne, IN | Registered: February 20, 2007Report This Post
Virtuoso
posted Hide Post
Javascript's toUpperCase is the key to your lock. Roll both sides of your comparison (not sure what your code does) to uppercase with this function and you should get a match.

J.

Reference: http://www.w3schools.com/jsref/jsref_toUpperCase.asp



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Reposition a Maintain Grid on a desired row

Copyright © 1996-2020 Information Builders