B4J Question (Solved) [B4X] B4XTable Column Id

aeric

Expert
Licensed User
Longtime User
Other fields that you can change are: Id, Searchable, Formatter, LabelIndex and DisableAutoResizeLayout. Not all of them will be covered in this tutorial.

You can also call GetColumn with the column id to get a column type. The id equals to the title by default (can be changed).

Q1: How can I change the column id?

Q2: After I have set the column id, can I use it with PreferenceDialog?

Eg: I have the title as "Birth Date" and key as "BirthDate" for PreferenceDialog json file, for B4XTable I have column header as "Birth Date" but I set the column id as "BirthDate" ?


 
Solution
Q1: How can I change the column id?

Q2: After I have set the column id, can I use it with PreferenceDialog?

Eg: I have the title as "Birth Date" and key as "BirthDate" for PreferenceDialog json file, for B4XTable I have column header as "Birth Date" but I set the column id as "BirthDate" ?


A1. Dim Col as B4xTableColumn
Col = B4xTable1.AddColumn("Title", B4xTable1.COLUMN_TYPE...)
Col.id = "YourId"
A2. I don't think it is relation with column id

teddybear

Well-Known Member
Licensed User
Q1: How can I change the column id?

Q2: After I have set the column id, can I use it with PreferenceDialog?

Eg: I have the title as "Birth Date" and key as "BirthDate" for PreferenceDialog json file, for B4XTable I have column header as "Birth Date" but I set the column id as "BirthDate" ?


A1. Dim Col as B4xTableColumn
Col = B4xTable1.AddColumn("Title", B4xTable1.COLUMN_TYPE...)
Col.id = "YourId"
A2. I don't think it is relation with column id
 
Upvote 0
Solution

aeric

Expert
Licensed User
Longtime User
A2. I don't think it is relation with column id

When I click Edit, I pass the data as a Map.
This Map has the key which is default to B4XTable header.
The problem I am facing when I use Localizator, the key header has changed to different language.
So I need a standard key disregard of different language.

B4X:
Dim Staff As Map = GrdStaff.GetRow(RowId)

1667971582002.png
 
Upvote 0

teddybear

Well-Known Member
Licensed User
When I click Edit, I pass the data as a Map.
This Map has the key which is default to B4XTable header.
The problem I am facing when I use Localizator, the key header has changed to different language.
So I need a standard key disregard of different language.

B4X:
Dim Staff As Map = GrdStaff.GetRow(RowId)
How do you do Localizator in PreferenceDialog?
I mean LoadFromJson.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
How do you do Localizator in PreferenceDialog?
I mean LoadFromJson.

This is how I done.

B4X:
    Select Main.SYSTEM_LANGUAGE.ToUpperCase
        Case "ZH-CN"
            Dim JsonString As String = File.ReadString(File.DirAssets, "template_staff_zh-cn.json")
        Case "ZH-TW"
            Dim JsonString As String = File.ReadString(File.DirAssets, "template_staff_zh-tw.json")
        Case Else
            Dim JsonString As String = File.ReadString(File.DirAssets, "template_staff_en.json")
    End Select
    PrefDialog2.LoadFromJson(JsonString)
 
Upvote 0

DarkoT

Active Member
Licensed User
When I click Edit, I pass the data as a Map.
This Map has the key which is default to B4XTable header.
The problem I am facing when I use Localizator, the key header has changed to different language.
So I need a standard key disregard of different language.

B4X:
Dim Staff As Map = GrdStaff.GetRow(RowId)

View attachment 135801
Maybe will be better when you will using query from data (which is inside of B4Xtable) - like this:

Example code:
    Dim tblOpravila as B4XTable
    
    ' c0 = ID in table, C1 = link, C2 ... C9 = name, c10 = date, ...
    Dim Query as String = "select * from data where c0 = " & Id
    Dim rs As ResultSet = tblOpravila.sql1.ExecQuery(Query)
    Dim rec As Map
    rec.Initialize
    Do While rs.NextRow
        rec.Put("id", rs.Getint("c0"))
        rec.Put("name", rs.GetString("c9"))
    Loop
    rs.Close

In this case you can create map with fixed ID-s...
 
Upvote 0
Top