CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Dynamic dropdown in an editable grid

Print topic Send  topic

Author Message
Roger Harris
Posted: 05/28/2003, 11:41 AM

I need some help developing a dynamic dropdown box, based on information
available in the editable grid. I'm using PHP, MySQL, and CCS 2.0.6.11.

In my editable grid, I have a field called SysCatID, an integer value. I
have tried leaving it a label, letting it be hidden, and letting it be a
textbox. SysCatID is also a field in another table. I want to limit the
products available in the drop-down box (a control called OptionID),
dependant upon the SysCatID.

This used to be simple in the old codecharge, but since I've moved up,
it seems like there's a heck of a learning curve :(

In the old codecharge, I would have just gone in and modified the SQL
string of the list-box to add a little where clause that would say:

...." where SysCatID=" . $fldSysCatID (this being a hidden field on the
form...)

but now, I have no idea what to do. When I try to add some kind of
parameter to determine what to base the where clause on, nothing works.
Do I use expression, form, application... or what??? The information
is right there in the editable grid, but I have no way of telling the
list-box what do use...

TIA,

Roger
DonB
Posted: 05/28/2003, 2:43 PM

I've been playing around with this today, and have come to the conclusion
you can't do it. From what I see, when you have a listbox in the editable
grid, there is a single datasource for values, for ALL rows. The
BeforeExecuteSelect and BeforeBuildSelect appear to execute only once per
page, so there is no way to change the "where" on a row by row basis, at
least within the normal CCS framework.

I think the best thing, where you have a dependency like this, is to NOT use
the editable grid but rather the conventional grid in conjunction with a
record form. Then you can control the listbox on a per-record basis and
have it show relevant choices for the row being edited.

While the Editable grid might be coerced into having a true dependent
listbox, I think doing that might be a bad idea - performance-wise - because
you'd have to hit the database once per row. And you'd do this for every
row, even if you never edit any of them.

There might be a way to do this by coding your own database lookup, and
building an array of values (this is an alternative way to populate the
listbox that CCS supports by way of the CCCreateDataSource function (in the
Classes module). Haven't been there, haven't done that.

One last disclaimer :-) is that my comments are relative to ASP 3.0, as I
have very little hands-on with any of the other CCS language options.

DonB


"Roger Harris" <roger@REMOVETHISbyapro.com> wrote in message
news:3ED5036D.7010903@REMOVETHISbyapro.com...
> I need some help developing a dynamic dropdown box, based on information
> available in the editable grid. I'm using PHP, MySQL, and CCS 2.0.6.11.
>
> In my editable grid, I have a field called SysCatID, an integer value. I
> have tried leaving it a label, letting it be hidden, and letting it be a
> textbox. SysCatID is also a field in another table. I want to limit the
> products available in the drop-down box (a control called OptionID),
> dependant upon the SysCatID.
>
> This used to be simple in the old codecharge, but since I've moved up,
> it seems like there's a heck of a learning curve :(
>
> In the old codecharge, I would have just gone in and modified the SQL
> string of the list-box to add a little where clause that would say:
>
> ..." where SysCatID=" . $fldSysCatID (this being a hidden field on the
> form...)
>
> but now, I have no idea what to do. When I try to add some kind of
> parameter to determine what to base the where clause on, nothing works.
> Do I use expression, form, application... or what??? The information
> is right there in the editable grid, but I have no way of telling the
> list-box what do use...
>
> TIA,
>
> Roger
>

DonB
Posted: 05/28/2003, 2:50 PM

By way of example, see http://www.gotodon.com/Testdep.asp.

This displays every attempt to load the listbox's datasource (bracketed like
this: ">>>>"value"<<<<"). Although there are two rows with data (and 3
empty rows), you can see that the listbox datasource is modified each time a
row is loaded into the grid, but only one of them has any effect. In the
example, I am modifying the "where" clause in the BeforeShowRow but all rows
see the same "where" (the one that belongs with the first row of the grid.

DonB


"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
news:bb3ah7$9u$1@news.codecharge.com...
> I've been playing around with this today, and have come to the conclusion
> you can't do it. From what I see, when you have a listbox in the editable
> grid, there is a single datasource for values, for ALL rows. The
> BeforeExecuteSelect and BeforeBuildSelect appear to execute only once per
> page, so there is no way to change the "where" on a row by row basis, at
> least within the normal CCS framework.
>
> I think the best thing, where you have a dependency like this, is to NOT
use
> the editable grid but rather the conventional grid in conjunction with a
> record form. Then you can control the listbox on a per-record basis and
> have it show relevant choices for the row being edited.
>
> While the Editable grid might be coerced into having a true dependent
> listbox, I think doing that might be a bad idea - performance-wise -
because
> you'd have to hit the database once per row. And you'd do this for every
> row, even if you never edit any of them.
>
> There might be a way to do this by coding your own database lookup, and
> building an array of values (this is an alternative way to populate the
> listbox that CCS supports by way of the CCCreateDataSource function (in
the
> Classes module). Haven't been there, haven't done that.
>
> One last disclaimer :-) is that my comments are relative to ASP 3.0, as I
> have very little hands-on with any of the other CCS language options.
>
> DonB
>
>
> "Roger Harris" <roger@REMOVETHISbyapro.com> wrote in message
>news:3ED5036D.7010903@REMOVETHISbyapro.com...
> > I need some help developing a dynamic dropdown box, based on information
> > available in the editable grid. I'm using PHP, MySQL, and CCS 2.0.6.11.
> >
> > In my editable grid, I have a field called SysCatID, an integer value. I
> > have tried leaving it a label, letting it be hidden, and letting it be a
> > textbox. SysCatID is also a field in another table. I want to limit the
> > products available in the drop-down box (a control called OptionID),
> > dependant upon the SysCatID.
> >
> > This used to be simple in the old codecharge, but since I've moved up,
> > it seems like there's a heck of a learning curve :(
> >
> > In the old codecharge, I would have just gone in and modified the SQL
> > string of the list-box to add a little where clause that would say:
> >
> > ..." where SysCatID=" . $fldSysCatID (this being a hidden field on the
> > form...)
> >
> > but now, I have no idea what to do. When I try to add some kind of
> > parameter to determine what to base the where clause on, nothing works.
> > Do I use expression, form, application... or what??? The information
> > is right there in the editable grid, but I have no way of telling the
> > list-box what do use...
> >
> > TIA,
> >
> > Roger
> >
>
>

Roger Harris
Posted: 05/30/2003, 2:38 PM

I finally figured it out!!! It is possible!

In the original post I had written:

In my editable grid, I have a field called SysCatID, an integer value. I
have tried leaving it a label, letting it be hidden, and letting it be a
textbox. SysCatID is also a field in another table. I want to limit the
products available in the drop-down box (a control called OptionID),
dependant upon the SysCatID.

and DonB wrote:

you'd have to hit the database once per row. And you'd do this for
every row, even if you never edit any of them.

You are absolutely correct in this regard... it takes many extra
lookups, although there is no perceivable difference in execution
time... This isn't really a problem for me due to the nature of the
program I'm writing. It comes down to the way that CodeCharge Studio
handles the form's Show() event.

If you look at the code for the form Show event in the editable grid,
you will see that it actually populates the drop down box once, and only
once, before it moves on to populate the rest of the form's data source.
It does this with the Prepare() control level function. For instance,
mine looks like:

this->OptionID->Prepare();
this->ds->open();

So I had no hope, given the existing documentation, to change this....
until I noticed that the form had an event called "Before Show Row". I
added the following code into that event.

$builder_form->OptionID->ds->Where = " fs_prebuilt_options.SysCatID=" .
$builder_form->SysCatID->GetValue();
$builder_form->OptionID->Prepare();

As you can see, this means that for each row, I repopulate the OptionID
list-box with current information based on that particular row's SysCatID.

I would have done it a simpler way, but the application I was writing
requires this kind of flexibility, as it is for the customization of PC
Components, like when you are building your own PC on Dell's or
Gateway's website. Each dropdown box will hold the name of valid
products, and also a difference in price.

Thanks very much for your help!

Roger

DonB wrote:
> By way of example, see http://www.gotodon.com/Testdep.asp.
>
> This displays every attempt to load the listbox's datasource (bracketed like
> this: ">>>>"value"<<<<"). Although there are two rows with data (and 3
> empty rows), you can see that the listbox datasource is modified each time a
> row is loaded into the grid, but only one of them has any effect. In the
> example, I am modifying the "where" clause in the BeforeShowRow but all rows
> see the same "where" (the one that belongs with the first row of the grid.
>
> DonB
>
>
> "DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
>news:bb3ah7$9u$1@news.codecharge.com...
>
>>I've been playing around with this today, and have come to the conclusion
>>you can't do it. From what I see, when you have a listbox in the editable
>>grid, there is a single datasource for values, for ALL rows. The
>>BeforeExecuteSelect and BeforeBuildSelect appear to execute only once per
>>page, so there is no way to change the "where" on a row by row basis, at
>>least within the normal CCS framework.
>>
>>I think the best thing, where you have a dependency like this, is to NOT
>
> use
>
>>the editable grid but rather the conventional grid in conjunction with a
>>record form. Then you can control the listbox on a per-record basis and
>>have it show relevant choices for the row being edited.
>>
>>While the Editable grid might be coerced into having a true dependent
>>listbox, I think doing that might be a bad idea - performance-wise -
>
> because
>
>>you'd have to hit the database once per row. And you'd do this for every
>>row, even if you never edit any of them.
>>
>>There might be a way to do this by coding your own database lookup, and
>>building an array of values (this is an alternative way to populate the
>>listbox that CCS supports by way of the CCCreateDataSource function (in
>
> the
>
>>Classes module). Haven't been there, haven't done that.
>>
>>One last disclaimer :-) is that my comments are relative to ASP 3.0, as I
>>have very little hands-on with any of the other CCS language options.
>>
>>DonB
>>
>>
>>"Roger Harris" <roger@REMOVETHISbyapro.com> wrote in message
>>news:3ED5036D.7010903@REMOVETHISbyapro.com...
>>
>>>I need some help developing a dynamic dropdown box, based on information
>>>available in the editable grid. I'm using PHP, MySQL, and CCS 2.0.6.11.
>>>
>>>In my editable grid, I have a field called SysCatID, an integer value. I
>>>have tried leaving it a label, letting it be hidden, and letting it be a
>>>textbox. SysCatID is also a field in another table. I want to limit the
>>>products available in the drop-down box (a control called OptionID),
>>>dependant upon the SysCatID.
>>>
>>>This used to be simple in the old codecharge, but since I've moved up,
>>>it seems like there's a heck of a learning curve :(
>>>
>>>In the old codecharge, I would have just gone in and modified the SQL
>>>string of the list-box to add a little where clause that would say:
>>>
>>>..." where SysCatID=" . $fldSysCatID (this being a hidden field on the
>>>form...)
>>>
>>>but now, I have no idea what to do. When I try to add some kind of
>>>parameter to determine what to base the where clause on, nothing works.
>>> Do I use expression, form, application... or what??? The information
>>>is right there in the editable grid, but I have no way of telling the
>>>list-box what do use...
>>>
>>>TIA,
>>>
>>>Roger
>>>
>>
>>
>
>
DonB
Posted: 05/30/2003, 5:45 PM

Well, dang it, they should document these things. I was trying to figure
out what "Prepare()" was (had an idea it was in the Listcontrol class
somewhere). Since I use ASP, I did not find it, but I did find "Repopulate"
as a method and "isPopulated as a property.

Son-of-a-gun, all I needed to do was set isPopulated to false, and it works.
My problem all along was the underlying recordset was not being reloaded -
because I didn't know I needed to (or even that I could) tell it to reload.

DonB



"Roger Harris" <roger@REMOVETHISbyapro.com> wrote in message
news:3ED7CF61.2000606@REMOVETHISbyapro.com...
> I finally figured it out!!! It is possible!
>
> If you look at the code for the form Show event in the editable grid,
> you will see that it actually populates the drop down box once, and only
> once, before it moves on to populate the rest of the form's data source.
> It does this with the Prepare() control level function. For instance,
> mine looks like:
>
> this->OptionID->Prepare();
> this->ds->open();
>

Iain
Posted: 07/02/2003, 10:03 PM

This definitely helped me as well.

Thanks for working it out roger.



Iain

On Fri, 30 May 2003 17:38:41 -0400, Roger Harris
<roger@REMOVETHISbyapro.com> wrote:

>I finally figured it out!!! It is possible!
>
>In the original post I had written:
>
>In my editable grid, I have a field called SysCatID, an integer value. I
>have tried leaving it a label, letting it be hidden, and letting it be a
>textbox. SysCatID is also a field in another table. I want to limit the
>products available in the drop-down box (a control called OptionID),
>dependant upon the SysCatID.
>
>and DonB wrote:
>
>you'd have to hit the database once per row. And you'd do this for
>every row, even if you never edit any of them.
>
>You are absolutely correct in this regard... it takes many extra
>lookups, although there is no perceivable difference in execution
>time... This isn't really a problem for me due to the nature of the
>program I'm writing. It comes down to the way that CodeCharge Studio
>handles the form's Show() event.
>
>If you look at the code for the form Show event in the editable grid,
>you will see that it actually populates the drop down box once, and only
>once, before it moves on to populate the rest of the form's data source.
> It does this with the Prepare() control level function. For instance,
>mine looks like:
>
>this->OptionID->Prepare();
>this->ds->open();
>
>So I had no hope, given the existing documentation, to change this....
>until I noticed that the form had an event called "Before Show Row". I
>added the following code into that event.
>
>$builder_form->OptionID->ds->Where = " fs_prebuilt_options.SysCatID=" .
>$builder_form->SysCatID->GetValue();
>$builder_form->OptionID->Prepare();
>
>As you can see, this means that for each row, I repopulate the OptionID
>list-box with current information based on that particular row's SysCatID.
>
>I would have done it a simpler way, but the application I was writing
>requires this kind of flexibility, as it is for the customization of PC
>Components, like when you are building your own PC on Dell's or
>Gateway's website. Each dropdown box will hold the name of valid
>products, and also a difference in price.
>
>Thanks very much for your help!
>
>Roger
>
>DonB wrote:
>> By way of example, see http://www.gotodon.com/Testdep.asp.
>>
>> This displays every attempt to load the listbox's datasource (bracketed like
>> this: ">>>>"value"<<<<"). Although there are two rows with data (and 3
>> empty rows), you can see that the listbox datasource is modified each time a
>> row is loaded into the grid, but only one of them has any effect. In the
>> example, I am modifying the "where" clause in the BeforeShowRow but all rows
>> see the same "where" (the one that belongs with the first row of the grid.
>>
>> DonB
>>
>>
>> "DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
>>news:bb3ah7$9u$1@news.codecharge.com...
>>
>>>I've been playing around with this today, and have come to the conclusion
>>>you can't do it. From what I see, when you have a listbox in the editable
>>>grid, there is a single datasource for values, for ALL rows. The
>>>BeforeExecuteSelect and BeforeBuildSelect appear to execute only once per
>>>page, so there is no way to change the "where" on a row by row basis, at
>>>least within the normal CCS framework.
>>>
>>>I think the best thing, where you have a dependency like this, is to NOT
>>
>> use
>>
>>>the editable grid but rather the conventional grid in conjunction with a
>>>record form. Then you can control the listbox on a per-record basis and
>>>have it show relevant choices for the row being edited.
>>>
>>>While the Editable grid might be coerced into having a true dependent
>>>listbox, I think doing that might be a bad idea - performance-wise -
>>
>> because
>>
>>>you'd have to hit the database once per row. And you'd do this for every
>>>row, even if you never edit any of them.
>>>
>>>There might be a way to do this by coding your own database lookup, and
>>>building an array of values (this is an alternative way to populate the
>>>listbox that CCS supports by way of the CCCreateDataSource function (in
>>
>> the
>>
>>>Classes module). Haven't been there, haven't done that.
>>>
>>>One last disclaimer :-) is that my comments are relative to ASP 3.0, as I
>>>have very little hands-on with any of the other CCS language options.
>>>
>>>DonB
>>>
>>>
>>>"Roger Harris" <roger@REMOVETHISbyapro.com> wrote in message
>>>news:3ED5036D.7010903@REMOVETHISbyapro.com...
>>>
>>>>I need some help developing a dynamic dropdown box, based on information
>>>>available in the editable grid. I'm using PHP, MySQL, and CCS 2.0.6.11.
>>>>
>>>>In my editable grid, I have a field called SysCatID, an integer value. I
>>>>have tried leaving it a label, letting it be hidden, and letting it be a
>>>>textbox. SysCatID is also a field in another table. I want to limit the
>>>>products available in the drop-down box (a control called OptionID),
>>>>dependant upon the SysCatID.
>>>>
>>>>This used to be simple in the old codecharge, but since I've moved up,
>>>>it seems like there's a heck of a learning curve :(
>>>>
>>>>In the old codecharge, I would have just gone in and modified the SQL
>>>>string of the list-box to add a little where clause that would say:
>>>>
>>>>..." where SysCatID=" . $fldSysCatID (this being a hidden field on the
>>>>form...)
>>>>
>>>>but now, I have no idea what to do. When I try to add some kind of
>>>>parameter to determine what to base the where clause on, nothing works.
>>>> Do I use expression, form, application... or what??? The information
>>>>is right there in the editable grid, but I have no way of telling the
>>>>list-box what do use...
>>>>
>>>>TIA,
>>>>
>>>>Roger
>>>>
>>>
>>>
>>
>>

   


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

Web Database

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.