Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By sgkalluri
#793741
Hello everyone,

I get a feeling that this question may have been asked earlier. Nevertheless, I am posting the same again...

I know the method of using dependent variables in a drop down by using @#DepVariable in the Sql query for the drop down.

However the same method does not seem to be working when the drop down is one of the columns of a grid. The sql query for that drop down column works fine when there is no dependent variable being referred to. However, no drop down values are populated when a dependent variable is provided in its query.

Is this an expected outcome?

Best wishes,
SGK
By sgkalluri
#793750
Thanks a lot Amos!

So, would this mean that an SQL query would be fired every time a row is added? Seems so in the tests that I did.

Also, on addition of a new row to the grid, the drop down values do not get populated automatically. They get populated only if the independent field is changed. To ensure that the drop down gets populated automatically, in Javascript I have to copy the current value of the independent field to a Javascript variable, set the independent field to some value other than its current value, then copy back the current value from the Javascript variable. All this leads to SQL queries getting fired in the drop down column of the grid. If there are large # of rows, then there is a slowness in the drop down columns getting populated.

Is this expected? Or maybe I would have done something wrong. I used the form that was attached in the topic viewtopic.php?f=41&t=710265&p=789979#p789979.

Best wishes,
SGK
User avatar
By amosbatto
#793752
sgkalluri wrote:So, would this mean that an SQL query would be fired every time a row is added? Seems so in the tests that I did.
Yes, it requeries every time a new row is added if you are using this code and have a recent version of PM:
Code: Select all
$("#mygrid").onAddRow(function(aNewRow, oGrid, rowIndex) {
    //change 2 to the column position of the hidden text field:
    aNewRow[2].setValue( $("#selectUserId").getValue() );
})
sgkalluri wrote:Also, on addition of a new row to the grid, the drop down values do not get populated automatically. They get populated only if the independent field is changed. To ensure that the drop down gets populated automatically, in Javascript I have to copy the current value of the independent field to a Javascript variable, set the independent field to some value other than its current value, then copy back the current value from the Javascript variable. All this leads to SQL queries getting fired in the drop down column of the grid. If there are large # of rows, then there is a slowness in the drop down columns getting populated.
I don't see that problem. This line of code automatically updates the list of options in the dependent field in the grid in PM 3.2:
Code: Select all
    aNewRow[2].setValue( $("#selectUserId").getValue() );
Which version of PM are you using?
By sgkalluri
#793757
Hello Amos,

I am using version 3.1.3. I use Google Chrome most of the time.

I think the issue is the aNewRow parameter. Inspection of the page reveals that there is no associated setValue function.

So, I tried the following...

oGrid.setValue( $("#selectUserId").getValue() , rowIndex, 2);

, and this worked.

Thanks,
SGK

I have a suggest where user have to select some do[…]

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]