Tabulator Array JS

Just starting out? Need help? Post your questions and find answers here.
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Tabulator Array JS

Post by skinkairewalker »

hello everyone !!

have a way to insert line like this > " {id:1, partida:"Desportiva Ferroviaria X Itapemirim", data:"20/02/2020", hora:"20:15", casa:1.91, emp:3.32, fora:3.46, amb:1.75, plusonefive:1.18,plus:"Ver Mais" , gender:"Brazil: Campeonato Capixaba"} " individually with array.add or using SB native commands ?

code >

Code: Select all

  Tabulator::SetAttribute2(#myTabulatorGadget, Tabulator::#TabulatorColumns, Columns())
  
  Protected SampleData
  
  
  
  ! v_sampledata = [
  !		{id:1,  partida:"Desportiva Ferroviaria X Itapemirim", data:"20/02/2020",  hora:"20:15",   casa:1.91, emp:3.32, fora:3.46, amb:1.75, plusonefive:1.18,plus:"Ver Mais" , gender:"Brazil: Campeonato Capixaba"},
  !   {id:2,  partida:"Estrela do Norte X Linhares", data:"20/02/2020",  hora:"20:15",   casa:1.53, emp:3.81, fora:4.98, amb:1.89, plusonefive:1.18,plus:"Ver Mais" , gender:"Brazil: Campeonato Capixaba"},
  !   {id:3,  partida:"Serra X SAO Mateus", data:"20/02/2020",  hora:"20:15",   casa:1.54, emp:3.61, fora:5.35, amb:2.13, plusonefive:1.26,plus:"Ver Mais" , gender:"Brazil: Campeonato Capixaba"},
  !   {id:4,  partida:"Boavista X Flamengo RJ", data:"22/02/2020",  hora:"18:00",   casa:11.3, emp:6.54, fora:1.16, amb:"", plusonefive:"",plus:"Ver Mais" , gender:"Brazil: Campeonato Carioca"},
  !	];  

  
  Tabulator::SetAttribute(#myTabulatorGadget, Tabulator::#TabulatorData, SampleData)
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Tabulator Array JS

Post by Peter »

For example, you can use LinkedLists:

Code: Select all

Structure sItem
  id.s
  partida.s
  xdata.s
  hora.s
  casa.s
  emp.s
  fora.s
  amb.s
  plusonefive.s
  plus.s
  gender.s
EndStructure

NewList Items.sItem()

AddElement(Items())
Items()\id = "1"
Items()\partida = "Desportiva Ferroviaria X Itapemirim"
Items()\xdata = "20/02/2020"
Items()\hora = "20:15"
Items()\casa = "1.91"
Items()\emp = "3.32"
Items()\fora = "3.46"
Items()\amb = "1.75"
Items()\plusonefive = "1.18"
Items()\plus = "Ver Mais"
Items()\gender = "Brazil: Campeonato Capixaba"

AddElement(Items())
Items()\id = "2"
Items()\partida = "Estrela do Norte X Linhares"
Items()\xdata = "20/02/2020"
Items()\hora = "20:15"
Items()\casa = "1.53"
Items()\emp = "3.81"
Items()\fora = "4.98"
Items()\amb = "1.89"
Items()\plusonefive = "1.18"
Items()\plus = "Ver Mais"
Items()\gender = "Brazil: Campeonato Capixaba"

; ... and so on

Define SampleData.s

CreateJSON(0)
InsertJSONList(JSONValue(0), Items())
SampleData = ComposeJSON(0)
FreeJSON(0)

Debug SampleData
Please note: There is a data property in your JSON. The SpiderBasic IDE recognizes data as a keyword and converts it to Data (with a capital 'D').
If it is somehow possible, you should use a different name for 'data' or you can outsource the structure to an external file.

Greetings ... Peter
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Tabulator Array JS

Post by skinkairewalker »

Peter wrote:For example, you can use LinkedLists:

Code: Select all

Structure sItem
  id.s
  partida.s
  xdata.s
  hora.s
  casa.s
  emp.s
  fora.s
  amb.s
  plusonefive.s
  plus.s
  gender.s
EndStructure

NewList Items.sItem()

AddElement(Items())
Items()\id = "1"
Items()\partida = "Desportiva Ferroviaria X Itapemirim"
Items()\xdata = "20/02/2020"
Items()\hora = "20:15"
Items()\casa = "1.91"
Items()\emp = "3.32"
Items()\fora = "3.46"
Items()\amb = "1.75"
Items()\plusonefive = "1.18"
Items()\plus = "Ver Mais"
Items()\gender = "Brazil: Campeonato Capixaba"

AddElement(Items())
Items()\id = "2"
Items()\partida = "Estrela do Norte X Linhares"
Items()\xdata = "20/02/2020"
Items()\hora = "20:15"
Items()\casa = "1.53"
Items()\emp = "3.81"
Items()\fora = "4.98"
Items()\amb = "1.89"
Items()\plusonefive = "1.18"
Items()\plus = "Ver Mais"
Items()\gender = "Brazil: Campeonato Capixaba"

; ... and so on

Define SampleData.s

CreateJSON(0)
InsertJSONList(JSONValue(0), Items())
SampleData = ComposeJSON(0)
FreeJSON(0)

Debug SampleData
Please note: There is a data property in your JSON. The SpiderBasic IDE recognizes data as a keyword and converts it to Data (with a capital 'D').
If it is somehow possible, you should use a different name for 'data' or you can outsource the structure to an external file.

Greetings ... Peter
thanks this working fine !!
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Tabulator Array JS

Post by skinkairewalker »

how can i get a values from clicked row ?
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Tabulator Array JS

Post by Peter »

skinkairewalker wrote:how can i get a values from clicked row ?
in your case:

Code: Select all

Procedure TabulatorEvents(o)
  
Select EventType()
  Case Tabulator::#EventType_RowClick
    Debug "#EventType_RowClick"
    Protected SelectedRow.sItem
    ! v_selectedrow = v_o.row.row.data;
    ; now you can work with SelectedRow
  Case ....
    [...]
EndSelect
  
EndProcedure
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Tabulator Array JS

Post by skinkairewalker »

Peter wrote:
skinkairewalker wrote:how can i get a values from clicked row ?
in your case:

Code: Select all

Procedure TabulatorEvents(o)
  
Select EventType()
  Case Tabulator::#EventType_RowClick
    Debug "#EventType_RowClick"
    Protected SelectedRow.sItem
    ! v_selectedrow = v_o.row.row.data;
    ; now you can work with SelectedRow
  Case ....
    [...]
EndSelect
  
EndProcedure

but how can i print values ?
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Tabulator Array JS

Post by Peter »

skinkairewalker wrote:but how can i print values ?
what do you mean by "print values"? Printing with a printer?
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Tabulator Array JS

Post by skinkairewalker »

print on debug , like > Debug(SelectedRow.id)
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: Tabulator Array JS

Post by skinkairewalker »

screenshot > https://prnt.sc/r70747

code >

Code: Select all

Procedure TabulatorEvents(o)
  
  Select EventType()
    Case Tabulator::#EventType_RowClick
      Debug "#EventType_RowClick"
      Protected SelectedRow.sItem
      Protected Items.s
      ! v_selectedrow = v_o.row.row.data;
      ! v_items=v_selectedrow;
      Debug SelectedRow
      
      Debug items
      
    Case Tabulator::#EventType_RowDblClick
      Debug "#EventType_RowDblClick"
    Case Tabulator::#EventType_RowContext
      Debug "#EventType_RowContext"
    Default
      Debug "EventType(): " + EventType()
  EndSelect
  
  Debug "---------------------------"
  
EndProcedure
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Tabulator Array JS

Post by Peter »

Code: Select all

[...]

    Case Tabulator::#EventType_RowClick

      Debug "#EventType_RowClick"

      Protected SelectedRow.sItem

      ! v_selectedrow = v_o.row.row.data;
      
      Debug SelectedRow\id
      Debug SelectedRow\partida
      Debug SelectedRow\xdata
      Debug SelectedRow\hora
      Debug SelectedRow\casa
      Debug SelectedRow\emp
      Debug SelectedRow\fora
      Debug SelectedRow\amb
      Debug SelectedRow\plusonefive
      Debug SelectedRow\plus
      Debug SelectedRow\gender
      
Post Reply