SalGridApplyState cant handle new Columns

Report TD 5.x and 6.x bugs and possible workarounds.
MWegner
Germany
Posts: 83
Joined: 11 Apr 2017, 07:39
Location: Germany

SalGridApplyState cant handle new Columns

Post by MWegner » 09 Jul 2015, 08:22

Hey folks,

SalGridWriteState and SalGridApplyState can't handle new columns in the grid.

Reprocase:

Step1: Open the application and add a few Lines with Button "New Line"
Step2: Sort the Columns so that col4 is in the first place, col3 in the second place and col1 is in the third place
Step3: Press the button "SalGridWriteState". The information is saved in an xml in the Folder of the apt

Step4: Close the application and uncomment "Column: col2" and "Set grid1.col2 = '2'"

Step5:Open the application again and add a few Lines with Button "New Line"
Step6: Press the Button "SalGridApplyState

Now the header of the columns are wrong (which is terrible) and the order is discussable (but I can live with that).

Background: Until now I done all of this on my own (order of columns) and got a pretty good (still not perfect) solution. But now my customers want to save the sorted and the grouped by information for the grids in my application. I can only save these information with these function. Am I right?

Addition: Why does this need to be an xml-File on the harddrive? I save this information in a database and always need to handle the temporary files. This is a performance issue.

Best regards
Martin

EDIT: TD Version: 6.2.3.44526 UPD1 Build 44526
Windows: Windows 7 Enterprise SP1
You do not have the required permissions to view the files attached to this post.
Last edited by Anonymous on 09 Jul 2015, 14:38, edited 1 time in total.

Uwe van der Horst
Site Admin
Site Admin
Germany
Posts: 628
Joined: 05 Mar 2017, 14:21
Location: Wetter (Ruhr), Germany

Re: SalGridApplyState cant handle new Columns

Post by Uwe van der Horst » 09 Jul 2015, 12:34

Hi Martin,

there is no attachment. You have to zip your testcase before uploading it.

Regards,
Best regards,
Uwe van der Horst
stp.one

MWegner
Germany
Posts: 83
Joined: 11 Apr 2017, 07:39
Location: Germany

Re: SalGridApplyState cant handle new Columns

Post by MWegner » 09 Jul 2015, 14:39

Thanks Uwe! I added the reprocase.

Uwe van der Horst
Site Admin
Site Admin
Germany
Posts: 628
Joined: 05 Mar 2017, 14:21
Location: Wetter (Ruhr), Germany

Re: SalGridApplyState cant handle new Columns

Post by Uwe van der Horst » 10 Jul 2015, 13:39

Hi Martin,

You write that SalGridApplyState can't handle new columns in the grid. Yes, you are right. But IMHO this is not a bug but rather something that have to do we developers.

Let’s have a look into the XML after saving your test case:
Grid_01.PNG

First, you see the VisibleIdx. It’s a consecutive number for VISIBLE columns, beginning with 0 for the first visible column.
If you hide e.g. “col3” before saving the grid state, you will get:
Grid_02.PNG

The ColIDs is a consecutive number for ALL columns, beginning with 32768. At the end you see the column name (= “Object Title” that you have typed in Attribute Inspector).
If you add, delete or even rename columns (e.g. if you change the Object Title because of a spelling mistake in your previous version), you have to think about the consequences for your customers. If not, the results are as in your test case after commenting in “col2”:
Grid_03.PNG
In the XML of your customers who have saved the Grid State there exists no “col2”. I don’t know how Gupta should this handle.
If you have to add a new column you can do this at the last position of your table, this should work for your customer without consequences. But in any other position it will fail.
There are even more things that you have to think about: Your customers might run into trouble after your application is calling “SalHideWindow” or “SalShowWindow” at runtime. If you really have the need to hide columns at runtime, you have to consider that your customer might have saved the Grid State when this column was visible or vice versa. The solution is not so easy. Before calling SalGridApplyState, you must open the XML and check if the column is visible or not. Make them visible and save the XML. Then call SalGridApplyState. After that is done, you can call “SalHideWindow”.

If VisDosExist( fGetXML( ) ) ! XML does exist?
...Call fShowColumn( col2 ) ! Set column to visible = yes in XML
...Call SalGridApplyState( )
...Call SalHideWindow( col2 )

I have attached some functions that are doing all this work for me. They are not documented well and this is not a working sample. I don’t have the time to do this for the moment. But maybe this helps.

Regards,
You do not have the required permissions to view the files attached to this post.
Best regards,
Uwe van der Horst
stp.one

MWegner
Germany
Posts: 83
Joined: 11 Apr 2017, 07:39
Location: Germany

Re: SalGridApplyState cant handle new Columns

Post by MWegner » 13 Jul 2015, 07:32

Hello Uwe,

thank you for the information. I'm handling this problem in a similar way to yours. Thanks for the code, this gave me some new good ideas.

I think the problem handling from the gupta functions is poorly at the moment. I know we as developer can work around this, but when the Gupta function reads an XML file with a different column count, there have to be a better way to handle the situation.

Best regards
Martin

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ahrefs], [Ccbot] and 4 guests