B4J Question [BANANO] JQWidget integration question

Discussion in 'B4J Questions' started by Luk, Apr 10, 2019.

  1. Luk

    Luk Member Licensed User

    Hi,

    I'm looking at BANano and possible integration with JQWidgets.
    How can I do the following in BANano:

    Code:
    $("#jqxButton").jqxButton({ width: 120, height: 40 });
    Thanks.
     
    Last edited: Apr 10, 2019
  2. alwaysbusy

    alwaysbusy Expert Licensed User

    Without knowing JQWidgets, I think something like that:

    Code:
    Dim jQ as BANanoObject
    jQ.Initialize(
    "$")
    JQ.Selector(
    "#jqxButton").RunMethod("jqxButton", CreateMap("width"120"height"40))
    Note that the JQ declaration can be done once in the Global
     
    Michael1968, Luk and Kiffi like this.
  3. Kiffi

    Kiffi Well-Known Member Licensed User

    Argh! Alain beats me ;)

    But nevertheless:

    Code:
    Sub Process_Globals
     
      
    Private BANano As BANano
     
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)

      BANano.Initialize(
    "BANanoJQWidgets""BANanoJQWidgets"1)
     
      BANano.UseServiceWorker = 
    False
     
      BANano.HTML_NAME = 
    "index.html"
     
      BANano.Header.Title = 
    "BANanoJQWidgets"

      BANano.Header.AddCSSFile(
    "https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css")
     
      BANano.Header.AddJavascriptFile(
    "https://code.jquery.com/jquery-3.3.1.min.js")
     
      BANano.Header.AddJavascriptFile(
    "https://jqwidgets.com/public/jqwidgets/jqx-all.js")

      BANano.Build(
    "C:\inetpub\wwwroot\BANano\"' <-- adjust to your needs!

      
    ExitApplication

    End Sub

    Sub BANanoJQWidgets_Ready()

      
    Dim HTML As String = $"<input type="button" value="Button" id="jqxbutton" />"$
     
      BANano.GetElement(
    "body").Append(HTML)
     
      
    Dim jQuery As BANanoObject
     
      jQuery.Initialize(
    "$")
     
      jQuery.Selector(
    "#jqxbutton").RunMethod("jqxButton", CreateMap("width":"150""height":"50"))
     
    End Sub
     
    Mashiane, Harris, Michael1968 and 2 others like this.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    @Kiffi :D But yours is much more complete!
     
  5. Luk

    Luk Member Licensed User

    Attached Files:

  6. alwaysbusy

    alwaysbusy Expert Licensed User

    As you are using jQuery, just continue with it:

    Code:
    Dim event As BANanoEvent ' dummy declaration so B4J doesn't give an error in the next line for the param of the callback
    mJRating.RunMethod("bind"Array("change", BANano.CallBack(mCallBack, mEventName & "_change"event))) ' _change must be lowercase!
    Absolutely! As you are making it as a Custom View, you can just use the Abstract Designer, drop one of your jqxRating objects on in and use the generate members method. Just adding some simple normal B4J code et voila! :)

    e.g. does the same as your manual code:
    Code:
    Sub BANanoJQWidgets_Ready()
       BANano.LoadLayout(
    "#body""layout1")
    End Sub

    Sub jqxRating1_Change (event As BANanoEvent)
       BANano.Alert(
    "ok")
    End Sub
    Alwaysbusy
     
    Last edited: Apr 10, 2019
    Luk and joulongleu like this.
  7. alwaysbusy

    alwaysbusy Expert Licensed User

    For the moment, to get the value from the event you will have to use this workaround:

    Code:
    Sub jqxRating1_Change (event As BANanoEvent)
       
    Dim ev As BANanoObject
       ev.Initialize(
    event)
       
    Log(ev.GetField("value"))
       BANano.Alert(
    "ok")
    End Sub
    I'll add .value and a method .otherField(name) for any other field which is not wrapped.

    So this will do the same:

    Code:
    Log(event.Value)   
    Log(event.OtherField("value"))
     
    Michael1968, Kiffi and Luk like this.
  8. Kiffi

    Kiffi Well-Known Member Licensed User

    very good! :)

    Greetings ... Peter
     
  9. alwaysbusy

    alwaysbusy Expert Licensed User

    Michael1968, Luk and Kiffi like this.
  10. Luk

    Luk Member Licensed User

    Here I am again :)

    I'm trying to call the function disable.
    Code:
    $('#jqxRating').jqxRating('disable');
    But the following is not working:
    Code:
    mJRating.RunMethod("jqxRating","").RunMethod("disable","")
    (I'm using version 2.39)

    Thanks.
     

    Attached Files:

  11. alwaysbusy

    alwaysbusy Expert Licensed User

    Shouldn't it be? (untested)

    Code:
    mJRating.RunMethod("jqxRating","disable")
    as 'disable' seems like a param of the method jqxRating
     
    Luk likes this.
  12. Luk

    Luk Member Licensed User

    It's working like a charm now. Thanks !
     
    alwaysbusy likes this.
  13. Kiffi

    Kiffi Well-Known Member Licensed User

    From the jQWidgets-Documentation (here for a jqxButton-button):
    so, the BANanoCode looks like this:
    Code:
    jQuery.Selector("#jqxbutton").RunMethod("jqxButton", CreateMap("disabled":True))
    // Edit: Note to me: always wait at least one hour for Alain before I answer. ;)
     
  14. Luk

    Luk Member Licensed User

    Another question ...

    Using
    Code:
    j = BANano.Window.GetField("JQXElements")
    I can obtain the JQXElements object, but how can I do the following ?

    Code:
    JQXElements.settings["buttonSettings"] =
            {
               width:
    120,height:40, value:"Button", theme:"light"
            
    }
    Creating the wrong code was no problem :)
    Code:
    j.RunMethod("buttonSettings", CreateMap("width":120"height":40,"theme":"light","value":"button"))
    Thanks
     
  15. Kiffi

    Kiffi Well-Known Member Licensed User

    untested:
    Code:
    j.RunMethod("settings"Array("buttonSettings", CreateMap("width":120"height":40,"theme":"light","value":"button")))
     
  16. alwaysbusy

    alwaysbusy Expert Licensed User

    Untested, but try this:

    Code:
    Dim j As BANanoObject = BANano.Window.GetField("JQXElements").GetField("settings")
    j.SetField(
    "buttonSettings", CreateMap("width":120"height":40,"theme":"light","value":"button"))
     
  17. alwaysbusy

    alwaysbusy Expert Licensed User

    @Kiffi Now you've beaten me :)
     
  18. Kiffi

    Kiffi Well-Known Member Licensed User

    @alwaysbusy :

    [​IMG]

    (but I think your solution is more correct)
     
    Harris, alwaysbusy and Luk like this.
  19. alwaysbusy

    alwaysbusy Expert Licensed User

    I wonder if both solutions work, as we seem to have taken a different approach to include the 'settings' @Luk can you test?
     
  20. Luk

    Luk Member Licensed User

    This code isn't working. The error message : settings is not a function ...
    Sorry Kiffi :)
    This code is working and will make my life a lot easier :)
    @Kiffi
    @alwaysbusy
    Thank you very much !
     
    Kiffi and alwaysbusy like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice