CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 navgrid -can't get record details

Print topic Send  topic

Author Message
NickM

Posts: 44
Posted: 03/30/2004, 4:42 AM

Hi all,
I've been playing with CCS and am having a little "understanding problem".
According to the navgrid example:
"Click on an employee name to view detailed information" - that's all I want to do with my little experiment.
I've set up a couple pages with grids, following the navgrid docs.
and I have one table (using php, MySQL, WinXP).
In the first page that shows the list, I have links that show this
xxx.php?ID=123
which is OK
But when I click on the link to go to the details page, the page has no details (empty grid).
I asume the info is not parsing the ID?.
Is there some custom code needed somewhere, or do I need to set something up in the details page to read the ID?

Hope someone can help with this newbie problem.

View profile  Send private message
peterr


Posts: 5971
Posted: 03/30/2004, 1:03 PM

Please take a look at the "Data Source" section at http://docs.codecharge.com/studio/html/UserGuide/Forms/RecordForm.html
There are 2 screenshot showing how to setup the parsing of the "user_id", which is the key to that sample form. You'd need to setup a similar parameter for your key value passed via the URL.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 03/31/2004, 5:17 AM

Thanks, that worked great! And so simple.:-D
Now to add some more functionality (one bit at a time...)
I'd like to be able to add a forward-back option to the details page but because I've used a form and not a grid this is not easily available.
Any suggestion of where to look for a solution?
View profile  Send private message
donsafar


Posts: 90
Posted: 03/31/2004, 7:46 AM

Look in the CCS Example Pack for Record Maintenance with Navigation.
_________________
Don Safar
View profile  Send private message
peterr


Posts: 5971
Posted: 03/31/2004, 1:15 PM

Let me add that there is one more related example in CCS Example Pack: Multi-step Registration ( http://examples.codecharge.com/ExamplePack/MultiStepReg...gistration1.php )
The "Record Maintenance with Navigation" example actually uses the Editable Grid for this ( http://examples.codecharge.com/ExamplePack/NavRecordGrid/NavRecordGrid.php )
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/01/2004, 8:49 PM

Thanks, correct solution --- wrong question (I wasn't clear enough:-/).
The solution presented allows me to move between fields in the one record (correct?)
However, what I would like to do is move onto the next record -- forward and back, viewing the information for each record (instead of having to go back to the list and selecting the next record).
Sorry about that. Where would you suggest I seek a solution this time (I have to admit this is one great program).

Regards, Nick
View profile  Send private message
peterr


Posts: 5971
Posted: 04/01/2004, 10:21 PM

Both examples listed above do exactly that. Haven't you look at them?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/01/2004, 10:31 PM

Yes I have looked at them and implemented one of them, but I don't move back or forward.
That's why I thought it just moved through the fields of one record rather than between records.
But if you say that the examples should have me moving between records, then I'll go back and have another try.
View profile  Send private message
peterr


Posts: 5971
Posted: 04/01/2004, 10:46 PM

Oops, the 2nd example indeed works differently. Though the first example mentioned by Don is moving between the records (using the Editable Grid). Is this the one you tried implementing? If it doesn't work well for you, what type of issues are you experiencing?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/01/2004, 11:05 PM

Actually I went with your first suggestion because I could get the record to show (using the form rather than the Grid) and then, as you suggested, I tried multistep registration to move along the records - but that is not what it does.
I have tried the NavGrid example which seems to do exactly what I want but I got lost when I had to insert the custom code (you have to change all the field names in the code to suit your table - this is way too hard for a beginner).
Should I keep trying with the NavGrid example and seek help here as I work along?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/01/2004, 11:26 PM

Actually the NavGrid example has very little custom code from what I can see. I think that the main key is to make the Editable Grid look like a record (change the layout) and set the number of Records per Page to 1. Then you may not even need any custom code.

But I owe you one, so I created and tested another solution that could also be useful in certain situations.
I used the CCS Record Builder to create a Record form based on our "employees" table in the "Intranet" sample database. Then I added 2 buttons (not links like in NavGrid): "Previous" and "Next". Then I specified "Update" in the "Operation" property of both buttons, but left the "Return Page" property blank.
Then I created "OnClick" event for each of the buttons. In the "Previous" button's event I used this ASP code:
Dim PrevRecord  
PrevRecord = CCDLookUp("Max(emp_id)","employees","emp_id < " & CCGetFromGet("emp_id", 0),DBIntranetDB)  
Redirect = "NewPage1.asp?emp_id=" & PrevRecord
And in the "Next" button's event I used this code:
Dim NextRecord  
NextRecord = CCDLookUp("Min(emp_id)","employees","emp_id > " & CCGetFromGet("emp_id", 0),DBIntranetDB)  
Redirect = "NewPage1.asp?emp_id=" & NextRecord
(NewPage1 is the name of my page with the record)
This whole exercise took 10 minutes in ASP so it should be fairly simple, but could be extended to prevent going outside of the record range.
I don't program in PHP but I hope that you can easily convert it to PHP if needed, or possibly someone else here would help.
Actually, I "stole" the Redirect code from the "DoLogin" button of the Login page, which our Builders create automatically when you create the Login page. I'd recommend looking there and see how the OnClick Redirect is done in PHP.
In any case, the NavGrid example may actually work without any custom code, so please try it too.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/04/2004, 6:32 AM

Many thanks but coding has never been my strong point.
I went back and tried the navGrid example again and got a couple of steps further.
I can now click on the link from the list and be taken to the correct details page.
However, the forward-back links on the details page only show this:
First Prev 1 of 1 Next Last
BUT, if I go directly to the details page (not via the link in the list above) it shows this
First Prev 1 2 3 4 5 6 7 8 9 10 of 32 Next Last
Which is what I want.
Now all I have to do is get the navigation to work properly from the link in the list .
There must be some code change I need to make, any suggestions why the navigation does not work when going to the details page via the links in the list?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/04/2004, 1:28 PM

Please specify your grid name and the grid's page name, and provide the code that you wrote. Then I can check if it looks right.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/04/2004, 11:02 PM

OK. Here goes:
There are two pages
hms_list
hms_details

the Grid for both pages is called " homes"

The "homes" table has a number of fields but I am using these:
In "hms_list"
ID
suburb
price
catchline

In "hms_details"
ID
suburb
price
description
photoID

"ID" is not shown in the pages, I'm using it with the "Suburb" field, which I have turned into a link with this HrefSource:
hms_details.ccp
and this link parameter:
Type:DataSource Column
Parameter source: ID
Parameter Name: ID

The Suburb link in the LivePage is hms_details.php?ID=xxx

According to NavGrid example:
"Add code to the Grid's Before Show Row event as shown in the example. "

Here is my interpretation of that code:
<?php
//BindEvents Method @1-0EC04EDF
function BindEvents()
{
global $homes;
$homes->CCSEvents["BeforeShowRow"] = "homes_BeforeShowRow";
}
//End BindEvents Method

$CurrentRecord = 0;

//homes_BeforeShowRow @2-139CBDBD
function homes_BeforeShowRow()
{
$homes_BeforeShowRow = true;
//End homes_BeforeShowRow

//Custom Code @12-76E105C4
// -------------------------
global $homes;
global $CurrentRecord;

//Calculate the number of records up to the current page
$PreviousRecords = $homes->PageSize * ($homes->PageNumber-1);

//increment the homes count
$CurrentRecord = $CurrentRecord + 1;

//Calculate and store the current page number in the empBackPage parameter of the suburb link.
$homes->suburb->Parameters = CCGetQueryString("QueryString", "");
$homes->suburb->Parameters = CCAddParam($homes->suburb->Parameters, "suburbBackPage", $homes->PageNumber);

//Calculate and store each homes' record number in the homesPage parameter of their corresponding suburb link.
//This parameter is used automatically by the Navigator of the Grid on the detail page NavGrid_Detail.
$homes->suburb->Parameters = CCAddParam($homes->suburb->Parameters, "homesPage",$PreviousRecords + $CurrentRecord);


// Write your own code here.
// -------------------------
//End Custom Code

//Close homes_BeforeShowRow @2-21EE3468
return $homes_BeforeShowRow;
}
//End Close homes_BeforeShowRow


?>

In the hms_details page, the example says:
"In the Data Source property of the Grid, add a Where parameter similar to the parameter in the Data Source property of the Grid in the NavGrid page"
So, I have:
Source: homes
ID={ID}
(this is the same as for the grid in hms_list)

then is says:
Add a Link control below the Grid.
For the Link, set the Href Source property to the NavGrid page and add a Link Parameter with the following properties: Source Type = URL, Parameter Source = empBackPage and Parameter name = employeesPage.
Enter empBackPage in the Remove Parameters property of the Link.

OK, my interpretation is:
Source Type = URL, Parameter Source = suburbBackPage and Parameter name = homesPage.
Enter suburbBackPage in the Remove Parameters property of the Link.

BUT I have no idea where the ...BackPage parameter comes from, or what it does. In any event, Nothing of the link shows up on the page. Not even the name.

what do you think, do I have the wrong reference somewhere in the code or have I misunderstood completely the eample's instructions?

Thanks for persevering with me.
View profile  Send private message
peterr


Posts: 5971
Posted: 04/04/2004, 11:36 PM

For now the first potential problem I see is this:
Quote :
ID" is not shown in the pages, I'm using it with the "Suburb" field, which I have turned into a link with this HrefSource:
hms_details.ccp
and this link parameter:
Type:DataSource Column
Parameter source: ID
Parameter Name: ID

The Suburb link in the LivePage is hms_details.php?ID=xxx
When I look at the example I can see that the link is configured without any parameters. It is just a "clean" link that only points to the destination (detail) page. The "Remove Parameters" property also contains one parameter that should be removed "employeesPage" (could be homesPage in your case).
There can be other issues but it's difficult to anaylze so much information at once and figure all potential problems.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 12:07 AM

Peterr,
All I am trying to do is follow the instructions (word for word) to recreate the NavGrid using my table and data.
While I do this I'm also trying to understand how the program works.
I did not think it would be this difficult to do! It may be a reflection of the instructions being ambiguous, or my misinterpretation. Either way I'm starting to wonder about the effort put in and the result so far, compared with other ways of achieving the same goal...
Enough bitching.
When I click on the "Suburb" link in the "hms_lilst" page I go to the correct page in the hms_details page.
the "Suburb" link shows as: hms_details?ID=xxx (xxx is a number)
The problem lies in the page that I am taken to in that the navigation on that page does not work at all.

View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 12:18 AM

OK. I never worked with this example either, but I simply looked at the example and was able to see that your link is setup incorrectly. If I can see it even without looking at your project, then this really doesn't seem difficult, at least to me:-)
Also in our online version at http://examples.codecharge.com/ExamplePack/NavGrid/NavG...employeesPage=3 I do not see any "ID" therefore I deduct that this is the problem.
The instruction also do not mention setting up the "ID" for your link but only:
Quote :
In the Grid, change the emp_name field type from Label to Link. Then set the Href Source property to the second page (NavGrid_Detail) and enter employeesPage in the Remove Parameters property. "
(there is nothing about the "ID" that you setup in your link)
All you need is just make sure that the URL is correct. This only involves little debugging and if I can do this without your project than it may not be too difficult. I recommend that you focus on the link/URL. If it is wrong then you need to analyze how the link is setup and how your code works.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 12:24 AM

"and enter employeesPage in the Remove Parameters property."

What is employeesPage, and what would be my equivalent, would it be homesPage?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 12:37 AM

Yes. I answered this in my responses above...
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 1:12 AM

I forgot to mention that if I remove the ID then there is no reference to the correct page for the "suburb" link to go to.
How does the page know which link is clicked, to open that page?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 1:24 AM

Looking at the example again and at the quote above, again:
Quote :
In the Grid, change the emp_name field type from Label to Link. Then set the Href Source property to the second page (NavGrid_Detail) and enter employeesPage in the Remove Parameters property.
it looks like the destinage page must be specified.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 1:35 AM

How is the destination page specified, if there is no mention of such a thing in the example?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 2:02 AM

I just cited the above Quote from the documentation. For the 3rd time: "Then set the Href Source property to the second page (NavGrid_Detail)". I can see this text at http://examples.codecharge.com/ExamplePack/NavGrid/NavGrid_desc.php and in the example that I created like you did.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 5:44 PM

OK, back to basics for me.
Peterr,
I may be reading too much into the instruction in the example (and complicating things too much, unecessarily, therefore have troubles).
When the instructions say:
Quote :
Add code to the Grid's Before Show Row event as shown in the example.

I go to the example and find this code:

//Custom Code @22-2A29BDB7
global $employees;
global $CurrentRecord;

//Calculate the number of records up to the current page
$PreviousRecords = $employees->PageSize * ($employees->PageNumber-1);

//increment the employee count
$CurrentRecord = $CurrentRecord + 1;

//Calculate and store the current page number in the empBackPage parameter of the Emp_Name link.
$employees->emp_name->Parameters = CCGetQueryString("QueryString", "");
$employees->emp_name->Parameters = CCAddParam($employees->emp_name->Parameters, "empBackPage", $employees->PageNumber);

//Calculate and store each employee's record number in the employeesPage parameter of their corresponding Emp_Name link.
//This parameter is used automatically by the Navigator of the Grid on the detail page NavGrid_Detail.
$employees->emp_name->Parameters = CCAddParam($employees->emp_name->Parameters, "employeesPage",$PreviousRecords + $CurrentRecord);

//End Custom Code

Does this mean:
I cut a paste (only) this code into my example and then try and change everything to suit my table name, field name etc?

or
do I simply click on the "add code" link in my example (and do nothing else),
or
do I search through the example code to find the bits of code in the white spaces then cut, paste and change the code to suit my example?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 6:24 PM

If taken literally the instruction "Add code to the Grid's Before Show Row event as shown in the example. " should be interpreted as:
"click on the 'add code' and then manually add/type the code, using our example as an example."
In other words, the key is to understand the code (at least a little) so that you can write it yourself. The examples should not always be used exactly as they are because everyone has different needs, while examples can only show what's possible and how it could be done (but doesn't have to be).
Of course in the case of this particular example there is little room for interpretation and I understand that you want your pages to work in the same way. Therefore you would need to either copy the full code from our example into your page and then change everything to suit your table & field names, or cut/copy/paste & change the code to suit your needs. The result should be the same.
I understand that you do not feel like you can code, but I must say that when you add more features to an application you will always run into certain features that require little coding. Believe me, I am not a hard-core developer myself and couldn't write a PHP program, but I can achieve almost anything I want using the examples, the existing documentation and Google. In this example I can see that the custom code is a bit unusual, but there is very little of it so it isn't too bad.
Even if you make a mistake and it doesn't work, you could probably spend 10 minutes redoing it again until you get it right. Just watch the URL that comes out of that link and if the URL contains wrong parameters (different from our original example) then you will have indications of what's wrong.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 6:34 PM

Thanks Peterr but I have spent more like 8 hours trying to understand this program and make this example work.
Quote :
Just watch the URL that comes out of that link and if the URL contains wrong parameters (different from our original example) then you will have indications of what's wrong.
At the moment I am not getting any parameters out of the link. Where in the code is that set. If I concentrate on that, perhaps it will snap into place.
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 6:41 PM

I forgot to mention that CCS automatically generates code when I press "+" in the events. Do I delete all that and then copy/paste the example code?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 7:39 PM

There are only 6 lines of code and they all are used only to create those parameters. The code does not perform any other actions.

You should not delete the code generated by CCS when you press "+".
You should only copy these 6 lines of code from the example:
Dim CurrentRecord  
...  
Dim PreviousRecords  
  PreviousRecords = employees.PageSize * (employees.PageNumber-1)  
  CurrentRecord = CurrentRecord + 1  
  employees.Emp_Name.Parameters = CCAddParam(employees.Emp_Name.Parameters, "empBackPage", employees.PageNumber)  
  employees.Emp_Name.Parameters = CCAddParam(employees.Emp_Name.Parameters, "employeesPage", PreviousRecords + CurrentRecord)
(and mofiy this code accordingly to match your own page and form names)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
NickM

Posts: 44
Posted: 04/05/2004, 8:24 PM

Peterr, many many thanks.
It works... finally.
And the reason it did not work before - field names are case sensitive.
As soon as I replaced suburbs with Suburbs; voila!
Man, that was a tough lesson to learn.
Next adventure - turn the name of the image in the grid (the name is in my table) into the image itself - now, where is that covered I wonder...

View profile  Send private message
peterr


Posts: 5971
Posted: 04/05/2004, 10:00 PM

Great :-)

You can use the "Image" component/control for this (select "Add Image" in the Toolbox / Forms).
Then specify the database field containing the image in the "Control Source" property.
I think that this requies that your database contains the image path relative to the current path, or the full/absolute image path.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
 Page 1 of 2  Next Last


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.