B4J Question [SithasoDaisy] How to load SDUISelect with MySQL table records?

Enrico Fuoti

Active Member
Licensed User
Longtime User
Hello Mashiane,
I should select a SDUITextBox value from a drop-down list of items that should be filled from a mySQL table.
It is easy to do it in BVAD using the foreign-key field property, but i could not find a way to achieve this in Sithaso.
Is there a way to do it or is up to come?
thanks,
 

Mashiane

Expert
Licensed User
Longtime User
Hi, please update your question to be something like: How to load SDUISelect with MySQL table records?

ComboMySQL.gif


In the above example, we are loading the Category SDUISelect from MySQL categories table.

When a user selects a Transaction Type, the category combo is cleared and reloaded with new content.

B4X:
Sub LoadExpenseCategories
    'clear the global map variable
    expense_categories.Initialize 
    'initialize the mysql class
    Dim ec As SDUIMySQLE
    ec.Initialize("sithasodaisy", "expense_categories", "id", "")
    'link the mysql class to datasource
    app.SetBackEndMySQLE(ec)
    'we want the id and name fields
    ec.SelectAll(Array("id", "name"), Array("name"))
    ec.JSON = banano.CallInlinePHPWait(ec.MethodName, ec.Build)
    ec.FromJSON
    'we get the id and name fields from each object in the returned records
    'and create a map
    expense_categories = SDUIShared.GetKeyValues(True, ec.result, "id", "name")
    'load item to combo
    'cboCategory.SetItems(expense_categories)
End Sub

Now, when the type changes, load map of key values to sduiselect

B4X:
Private Sub cboTranType_Change (item As String)
    Select Case item
    Case ""
        cboCategory.Clear
    Case "expense"
        cboCategory.SetItems(expense_categories)
        'cboCategory.SetItems1(expense_categories, True)
    Case "income"    
        cboCategory.SetItems(income_categories)
        'cboCategory.SetItems1(income_categories, True)
    End Select
End Sub

We call the method like...

B4X:
Sub mounted
    banano.Await(LoadExpenseCategories)
    banano.Await(LoadIncomeCategories)    
    tblExpense.AddDisabled = True
    tblExpense.refreshloading = True
    dsExpense.SELECT_ALL
End Sub
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
hello, how to set a elemento into a SDUISelect
B4X:
'
'
'
'SDUITable1 is into ParentID SDUIModal1 
SDUITable1.AddPropertySelect("months", "Months", "", "", True, "left", mapMonths) 'January, February, March ... .... December
'
'
'how to set a element into mapMonths (example 2=March ?)
SDUIModal1.Show
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
hello, how to set a elemento into a SDUISelect
B4X:
'
'
'
'SDUITable1 is into ParentID SDUIModal1
SDUITable1.AddPropertySelect("months", "Months", "", "", True, "left", mapMonths) 'January, February, March ... .... December
'
'
'how to set a element into mapMonths (example 2=March ?)
SDUIModal1.Show
Please start a new thread for your question, and please provide more clarity. I dont understand your question.
 
Upvote 0
Top