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 -> ASP.NET - InMotion Framework

 Fix Navigator when SQL is modified

Print topic Send  topic

Author Message
rbaldwin

Posts: 172
Posted: 08/26/2014, 1:27 PM

In the before show event of my grid i've modified the sql such that fewer rows are being returned to the grid. However, the navigator is unaware of this. And now shows to many pages.

How to correct this?
View profile  Send private message
lsmashnuk

Posts: 13
Posted: 08/27/2014, 11:40 PM

The documentation is wrong. You have to modify SQL parameters in the Before Build Select Event.

Regards
LSmashnuk
View profile  Send private message
rbaldwin

Posts: 172
Posted: 08/28/2014, 5:34 AM

To be clear,
in Grid1_BeforeExecuteSelect, i had this code
dim sql as String = e.Command.CommandText
dim newsql as String = sql.replace("1=1","domainname = 'BNS'")

e.Command.CommandText = newsql


That does correctly change the number of rows returned to my Grid.

However if i move that code to the Before Build Select Event
an error is thrown. ": 'Common' is not a member of 'InMotion'."

So, i believe, that the BeforeExecuteSelect is the correct place.

I've done this many times before in 4.3 without inMotion and the BeforeExecuteSelect was the correct place to put it. However the navigator is unaware of the change to the SQL.

I believe the solution is in the AfterExecuteSelect i need to be able to modify
Grid1.TotalRows to reflect the new number of rows returned by the altered SQL
and
Grid1.TotalPages to reflect the new number of pages
however those two properties of Grid1 are readonly.

I've done the same thing in 4.3 without inMotion,

I believe that this is a problem that can't be resolved unless a change is made to the framework code.
I even think i know where the change in the Framework needs to be made, but i'm not a c# developer.
Unfortunately, support for the Framework is almost non-existent.
And for me not being able to correct the navigator is a major road block.
I have a maintenance license for CCS, and i have asked support, but i got back the typical "We have passed this to the developers", who seem to be silent these days.

View profile  Send private message
lsmashnuk

Posts: 13
Posted: 08/31/2014, 12:36 AM

Hello rbaldwin

I quite often add an additional where parameter to a Grid, that would then change the TotalRows and TotalPages values.
I add the code to the BeforeBuildSelect Event. The CCS documentation says to use the BeforeExecuteSelect Event but you have to use BeforeBuildSelect Event.
An example would be:

'Grid AUCTION Event Before Build Select. Action Custom Code @53-73254650
' -------------------------
' Write your own code here.
' -------------------------
If System.Web.HttpContext.Current.Application("Preview_Mode") = 0 Then
' filter out any Items over 1000 - Preview Mode is Off
Dim wparam As InMotion.Data.WhereParameter = New InMotion.Data.WhereParameter()
wparam.SourceColumn = "ITEM_NO"
wparam.ParameterName = "Expr144"
wparam.Type = DataType.Integer
wparam.Condition = WhereParameterCondition.LessThan
wparam.Operation = WhereParameterOperation.And
wparam.Value = System.Web.HttpContext.Current.Application("ItemNo_Ceiling")
e.Command.WhereParameters.Add(wparam)
End If
'End Grid AUCTION Event Before Build Select. Action Custom Code

Look at the C# code in InMotion.Web.Controls\MTDataSourceView.cs file. This class has the code that calls these Events.
The ExecuteSelect Interface starts at line 488.
OnBeforeBuildSelect event is called at line 527.
TotalRowCount property is set at line 573.
OnBeforeExecuteSelect event is called at line 582.
OnAfterExecuteSelect event is called at line 611.
The resulting dataset and row count is returned to the Grid and Navigator controls.

You mentioned :
However if i move that code to the Before Build Select Event
an error is thrown. ": 'Common' is not a member of 'InMotion'."
Are you sure you this was not a typo ? Maybe 'Common' should have been 'Command' ?

I have not tried modifying e.Command.CommandText but I see no reason why it should not work.

Regards
Layne Smashnuk


View profile  Send private message
rbaldwin

Posts: 172
Posted: 09/03/2014, 12:46 PM

I apologize, i did not receive an email that this thread had been updated. I will take a look at your suggestion, today. Thank you for getting back to me.
View profile  Send private message
rbaldwin

Posts: 172
Posted: 09/04/2014, 6:15 AM

Thank you Layne.

The solution you provide, does work, when the Data Source Type= Table, but if Data Source Type = SQL, then no.

Many of my grids require some queries with sub-queries. so thanks for your suggestion which i will be using, but, i also need a solution when my Data Source is SQL.

btw, i don't think the solution you suggest works using e.Command.CommandText = sql

Also, the solution does work when i'm displaying a Grid, but does not work when i'm displaying a Report.
View profile  Send private message
lsmashnuk

Posts: 13
Posted: 09/04/2014, 8:13 PM

Ok, now that I have a better idea of the context in which you are modifying the Command object,, I will check out the SQL and Report types and see if can help.

Regards
View profile  Send private message
lsmashnuk

Posts: 13
Posted: 10/02/2014, 11:26 PM

I have created an example of how to use a CCS InMotion VB Grid Control with some VB.Net code, to define the SQL Select command and most of the Grid properties. I'm sure YesSoftware expects developers to use the CCS Grid Builder and my example uses the Grid Control. All of the Grid Control properties are set using VB.Net code.
It may help you with the Navigator problem you had posted and possibly have more flexibility with SQL Select commands.
I could email the CCS project to you, if interested.

Regards
Layne Smashnuk
View profile  Send private message
rbaldwin

Posts: 172
Posted: 10/03/2014, 6:38 AM

Thanks Layne, i PM'd you with my email address please send your project there.
View profile  Send private message

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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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