Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 7 Monaten, 2 Wochen
Letzter Beitrag:
vor 7 Monaten, 2 Wochen
Beteiligte Autoren:
DW, Fabrice Harari

Webdev 22 pass paramter to JS function - Solved

Startbeitrag von DW am 06.01.2018 22:53

Hello All,

I need to pass data to a JS function that is formatted as JSON. if I use a button to create the data and call a local browser JS function and pass the data as a string.

[ { "title":"Jim Longer", "id":"1234", "start":"2018-01-12T10:30:00", "end":"2018-01-12T12:30:00" }, { "title":"Steve Smith", "id":"14", "start":"2018-03-12T10:30:00", "end":"2018-03-12T12:30:00" } ]

The function does not work.
If I hard code it in the JS function it works.

var eventData = [{"title":"Joe Moe","id":"123","start":"2018-01-12T10:30:00","end":"2018-01-12T12:30:00"},{"title":"Bill Smith","id":"456","start":"2018-01-14T10:30:00","end":"2018-01-14T12:30:00"}]

code of Function:

function lbp_FilterCalendar(sData){
header: {
center: 'week,twoweek,threeweek,fourweek' // buttons for switching between views
defaultView: 'week',

editable: true,
eventLimit: true, // allow "more" link when too many events
events: sData,
views: {
week: {
type: 'basic', /* 'basicWeek' ?? */
duration: { weeks: 1 },
buttonText: '1 Week'
twoweek: {
type: 'basic',
duration: { weeks: 2 },
buttonText: '2 Week'
threeweek: {
type: 'basic',
duration: { weeks: 3 },
buttonText: '3 Week'
fourweek: {
type: 'basic',
duration: { weeks: 4 },
buttonText: '4 Week'

Thanks DW


Re: Webdev 22 pass paramter to JS function

Hi Dennis

from your description, I'm guessing that your wlanguage code is incorrect, but as it's the ONE thing your are NOT showing us, I don't see how anybody could help.

Best regards

von Fabrice Harari - am 07.01.2018 11:55

Re: Webdev 22 pass paramter to JS function

Hello Fabrice,

I solved it.

The function needed the data to be a JSON object not a sting. Windev (Or I for that matter) was sending it as a string.

To fix it I used code below in the js function and it worked.
var json = JSON.parse(sData)

this is the code to build the data:

stJason is Structure
title is string
id is string
start is string
'end' is string

arrLoad is array of stJason
nRow is int
nRow = ArrayAdd(arrLoad)

arrLoad[nRow].title = "Jim Longer"
arrLoad[nRow].id = "1234"
arrLoad[nRow].start = "2018-01-12T10:30:00"
arrLoad[nRow].end = "2018-01-12T12:30:00"

nRow = ArrayAdd(arrLoad)

arrLoad[nRow].title = "Steve Meet"
arrLoad[nRow].id = "14"
arrLoad[nRow].start = "2018-01-13T10:30:00"
arrLoad[nRow].end = "2018-01-13T12:30:00"

bufJason is Buffer


von DW - am 07.01.2018 12:44
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.