amc
Posts: 22
|
Posted: 10/25/2012, 8:23 AM |
|
Hi,
As this is my first post, I want to say hello and give thanks for all the future help I could receive from this comunity...
I solved my problem but as I don't know a lot about Ajax I wanted to ask if it didn't work because I did something wrong...
- I have 2 listboxes and I use the dependent listboxes builder to link them.
- I build a query (in the builder) for the Slave Listbox Source. In this query I add two where conditions: one from a session variable and one from a URL parameter.
- Once finished all the process I saw that the URL parameter is not got by the Ajax service. Seeing the code I realize that the Ajax service is trying to get the URL parameter, but the HTML page is not sending it. The HTML only sends the parameter linking the 2 listboxes.
Code from the service:
function Show()
{
$Tpl = & CCGetTemplate($this);
global $CCSLocales;
if(!$this->Visible) return;
$this->RowNumber = 0;
$this->DataSource->Parameters["sesImplantatorUserID"] = CCGetSession("ImplantatorUserID", NULL);
$this->DataSource->Parameters["urlprojecte_id"] = CCGetFromGet("projecte_id", NULL);
$this->DataSource->Parameters["urlkeyword"] = CCGetFromGet("keyword", NULL);
.....
Above you see 3 params. The 1st one works. The 3rd one works. The 2nd one doesn't.
In the HTML page you see this:
function Contentsessio1empleat_idPTDependentListBox1_start(sender) {
.....
new Ajax.Request("services/Sessio_sessio1_empleat_id_PTDependentListBox1.php?keyword=" + sender.value, {
method: "get",
requestHeaders: ['If-Modified-Since', new Date(0)],
....
The 2nd parameter (projecte_id) is not added to the URL.
To solve it I added it manually:
new Ajax.Request("services/Sessio_sessio1_empleat_id_PTDependentListBox1.php?keyword=" + sender.value + "&projecte_id="+getParam('projecte_id'), {
Was I doing anything wrong?
Thanks
|
|
|
andrewi
Posts: 162
|
Posted: 10/25/2012, 11:33 AM |
|
Welcome to CCS ! Some of the Ajax features are fun. Are you using version 4 or 5 of CCS?
I don't think you did anything wrong. I think that the Ajax service builders by default only create one URL parameter - called 'keyword'.
If you want to use a second URL parameter (such as your 'projecte_id' then you have to add it manually.
(you first parameter 'ImplantatorUserID' is not a URL parameter but is a session variable, so this is not affected by the Ajax request)
So I think you did what had to be done. It's ideal if you can do this without editing "generated code" (the code that's grey shaded until you change it) because then CCS maintains the code for you, but in this case it might not be possible.
|
|
|
amc
Posts: 22
|
Posted: 10/25/2012, 11:45 AM |
|
I'm using CSS 5.
Thanks for your answer
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 10/30/2012, 3:16 AM |
|
I had a situation where I wanted the same WHERE filter on the master listbox and the slave listbox. It worked on the master, but not on the slave.
So i edited the dependent listbox code to filter by the URL parameter that I wanted called "siteid".
Another thing, if you ever run into problems with dependent listboxes check that all of them on your page have correctly configured event handlers in the html file. I have seen where one is not configured correctly will adversely affect all the others. I have read a lot of bad reports about DLB on this site, I have only ever gone to 2 listboxes but can say with the event handlers configured correctly and knowledge of where to place your WHERE statements for the slave, the prototype DLB's work fine.
Here is my services/dlb.php code filtered by siteid, you will notice I have put a ridiculously high limit on the number of records for fun, kids don't try this at home :)
//Class_Initialize Event @2-2B000687
function clsGridassettype($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->ComponentName = "assettype";
$this->Visible = True;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Grid assettype";
$this->Attributes = new clsAttributes($this->ComponentName . ":");
$this->DataSource = new clsassettypeDataSource($this);
$this->ds = & $this->DataSource;
$this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
$this->PageSize = 10000;
else
$this->PageSize = intval($this->PageSize);
if ($this->PageSize > 10000)
$this->PageSize = 10000;
if($this->PageSize == 0)
$this->Errors->addError("<p>Form: Grid " . $this->ComponentName . "<br>Error: (CCS06) Invalid page size.</p>");
$this->PageNumber = intval(CCGetParam($this->ComponentName . "Page", 1));
if ($this->PageNumber <= 0) $this->PageNumber = 1;
$this->idassettype = new clsControl(ccsLabel, "idassettype", "idassettype", ccsInteger, "", CCGetRequestParam("idassettype", ccsGet, NULL), $this);
$this->assettype = new clsControl(ccsLabel, "assettype", "assettype", ccsText, "", CCGetRequestParam("assettype", ccsGet, NULL), $this);
}
//End Class_Initialize Event
//Initialize Method @2-75D22D4D
function Initialize()
{
if(!$this->Visible) return;
$this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
}
//End Initialize Method
//Show Method @2-01180CBD
function Show()
{
$Tpl = & CCGetTemplate($this);
global $CCSLocales;
if(!$this->Visible) return;
$this->RowNumber = 0;
$this->DataSource->Parameters["urlsiteid"] = CCGetFromGet("siteid", NULL);
$this->DataSource->Parameters["urlkeyword"] = CCGetFromGet("keyword", NULL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);
$this->DataSource->Prepare();
$this->DataSource->Open();
$this->HasRecord = $this->DataSource->has_next_record();
$this->IsEmpty = ! $this->HasRecord;
$this->Attributes->Show();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
if(!$this->Visible) return;
$GridBlock = "Grid " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $GridBlock;
if (!$this->IsEmpty) {
$this->ControlsVisible["idassettype"] = $this->idassettype->Visible;
$this->ControlsVisible["assettype"] = $this->assettype->Visible;
while ($this->ForceIteration || ($this->HasRecord = $this->DataSource->has_next_record())) {
// Parse Separator
if($this->RowNumber) {
$this->Attributes->Show();
$Tpl->parseto("Separator", true, "Row");
}
$this->RowNumber++;
if ($this->HasRecord) {
$this->DataSource->next_record();
$this->DataSource->SetValues();
}
$Tpl->block_path = $ParentPath . "/" . $GridBlock . "/Row";
$this->idassettype->SetValue($this->DataSource->idassettype->GetValue());
$this->assettype->SetValue($this->DataSource->assettype->GetValue());
$this->Attributes->SetValue("rowNumber", $this->RowNumber);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow", $this);
$this->Attributes->Show();
$this->idassettype->Show();
$this->assettype->Show();
$Tpl->block_path = $ParentPath . "/" . $GridBlock;
$Tpl->parse("Row", true);
}
}
$errors = $this->GetErrors();
if(strlen($errors))
{
$Tpl->replaceblock("", $errors);
$Tpl->block_path = $ParentPath;
return;
}
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->DataSource->close();
}
//End Show Method
_________________
Central Coast, NSW, Australia.
|
|
|
|