Gridedit with field dropdown filter condition

This public forum is for user-to-user discussions of ASPMaker. Note that this is not support forum.

Gridedit with field dropdown filter condition

Postby yeehoy » Fri Dec 01, 2017 8:03 am

I'm testing ASPM 2018 with my current 2017 project to see if I should upgrade and came across a problem. I have a table "tablesurvey" with fields [Section], [Statement], [Rating] and I do a gridedit to capture the [Rating] with a table lookup for the [Rating] scale. I have a filter condition in the field where

"[Section]='" & tablesurvey.Section.CurrentValue & "'"

This works fine in my ASPM 2017 project and in 2018, it works fine in the List View, but when I use GridEdit, the lookup is empty. It works if I have an InLine Edit or just single row Edit.

I put it in the <table>list.asp

Call ew_AddFilter(sWhereWrk, sFilterWrk)
Call tblpmEmpStatements.Lookup_Selecting(tblpmEmpStatements.SelfRating, sWhereWrk) ' Call Lookup Selecting
Response.write sWhereWrk <-----------------------------------------------
If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
Set RsWrk = Server.CreateObject("ADODB.Recordset")
Call ew_SetDebugMsg("Lookup(DB): " & sSqlWrk) ' Show data for debugging
RsWrk.Open sSqlWrk, ew_GetConn("DB")

And the sWhereWrk shows the correct filter condition for each row. How do I test to see if the array "arwrk" returns the correct results?
yeehoy
 
Posts: 96
Joined: Wed Nov 21, 2012 11:14 am

Re: Gridedit with field dropdown filter condition

Postby Webmaster » Fri Dec 01, 2017 1:22 pm

The dropdown is loaded by Ajax.

1. To see the ajax response, use a browser that allow debug (e.g. Google Chrome). Go to the network tab. Run the grid edit page. Look for response from "ewlookup15.asp". It should be a json containing the data.

2. If the json data is empty, you need to show the executing SQL for debugging. Open ewlookup15.asp, add the following lines (see lines marked with ***):

' Get record count
Response.Write "sql: " & sql '***
Response.End '***
TotalRecs = ew_GetRecordCount(sql, DBID) ' ASP
If max <= 0 Then max = TotalRecs
Dim result
If isAutoSuggest Then ' ASP
sql = ew_GetSelectLimitSql(sql, max, offset, DBID)
End If
Set Recordset = Connection.Execute(sql)

Check the SQL. Run the SQL directly in your database to see why it did not return the correct data.
Webmaster
 
Posts: 10734
Joined: Fri Aug 06, 2004 5:59 pm

Re: Gridedit with field dropdown filter condition

Postby yeehoy » Fri Dec 01, 2017 2:01 pm

I tried to do as you suggest for ewlookup15.asp but got nothing.

It seems that the problem only exists if you try to use a filter condition which requires a value from the current row in GridEdit. It works fine in a normal ADD, EDIT or InLine ADD / EDIT.

Please help.
yeehoy
 
Posts: 96
Joined: Wed Nov 21, 2012 11:14 am

Re: Gridedit with field dropdown filter condition

Postby Webmaster » Mon Dec 04, 2017 12:33 pm

1. yeehoy wrote:
> I put it in the <table>list.asp
> Call ew_AddFilter(sWhereWrk, sFilterWrk)
> Call tblpmEmpStatements.Lookup_Selecting(tblpmEmpStatements.SelfRating, sWhereWrk)
> ' Call Lookup Selecting
> Response.write sWhereWrk <-----------------------------------------------
>And the sWhereWrk shows the correct filter condition for each row.

You checked the wrong place, the code tries to lookup the display based on the current value, not to load options for dropdown which, as explained, is loaded by Ajax. In v2018, the lookup filter for Ajax is set up only once for all rows BEFORE the records are loaded (so there is no value of tablesurvey.Section.CurrentValue yet).

2. >I tried to do as you suggest for ewlookup15.asp but got nothing.

If you do it correctly, you must see the SQL with the tablesurvey.Section.CurrentValue missing.

3. >It works fine in a normal ADD, EDIT or InLine ADD / EDIT.

For the reason explained above, it should only work in Edit page, it can't work in Add page, Inline/Grid-Add/Edit in List page because there is no CurrentValue yet when the lookup filter is being set up.

4. The lookup filter cannot be changed row by row by server side event. However, your filter can reserve a value (e.g. as "{query_value_1}") in the filter and you can replace that with the actual value (e.g posted as "q1") posted to server side as data of Ajax. A similar example can be found in help file: Server Events and Client Scripts -> Table-Specific -> Add/Copy page -> Client Script -> Example 2.
Webmaster
 
Posts: 10734
Joined: Fri Aug 06, 2004 5:59 pm

Re: Gridedit with field dropdown filter condition

Postby yeehoy » Mon Dec 04, 2017 2:24 pm

I don't understand what you mean

>> replace that with the actual value (e.g posted as "q1") posted to server side as data of Ajax

How do you post from the serverside to Ajax?
yeehoy
 
Posts: 96
Joined: Wed Nov 21, 2012 11:14 am

Re: Gridedit with field dropdown filter condition

Postby yeehoy » Wed Dec 13, 2017 12:28 pm

Don't know why they have made ASPM 2018 so complicated to do this. Used to work in 2017 version.

Does anyone know a simple way to show a dynamic dropdown list from a lookup table based on a read-only value in the row during GridEdit?
yeehoy
 
Posts: 96
Joined: Wed Nov 21, 2012 11:14 am

Re: Gridedit with field dropdown filter condition

Postby Webmaster » Thu Dec 14, 2017 10:41 am

Alternatively, set up the fields as dynamic selection list and then set the parent field to read only in the Page_Load server event:

If <Table>.CurrentAction = "edit" Or <Table>.CurrentAction = "gridedit" Then
<Table>.<ParentField>.ReadOnly = True
End If

You can also send your project/database to the support email for checking if you are a registered user.
Webmaster
 
Posts: 10734
Joined: Fri Aug 06, 2004 5:59 pm


Return to General Discussion (ASPMaker)