Toolbar MVVM

8 posts, 1 answers
  1. Bert
    Bert avatar
    29 posts
    Member since:
    May 2012

    Posted 21 Aug 2014 Link to this post

    Hello,

     I can bind a toolbar button click to a view model using the following code:

    $("#toolbarButton").attr("data-bind", "click: onButtonClick");
    var model = kendo.observable({
      onButtonClick: function () { alert(“Hello”) }
    });
    kendo.bind($("#Toolbar"), model);


    After disabling the button, it is grayed out but clicking on the button still calls the click handler. The button is disabled using the following code.

    var toolbar = $("#Toolbar").data("kendoToolBar");<br>toolbar.enable($("#toolbarButton"), false);

     Any help would be appreciated.

    Regards,

    Bert
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 22 Aug 2014 Link to this post

    Hi Bert,

    The ToolBar widget exposes two ways of attaching click event handlers. The first one is by using the click event of the widget and the second one is by using the click configuration property of the item.
    The code you provided binds the click configuration property of the item which is not supported. At present only binding the click event handler of the widget is supported.

    Please see the following example: http://dojo.telerik.com/eCEQ

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Bert
    Bert avatar
    29 posts
    Member since:
    May 2012

    Posted 25 Aug 2014 in reply to Alexander Valchev Link to this post

    Hello Alexander,

    will MVVM support like binding the click configuration property be available in the next service release? We are also missing the razor function for setting html-attributes.

    Kind regards,
    Bert

  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 26 Aug 2014 Link to this post

    Hello Bert,

    As a general rule, configuration properties of the widgets cannot be bound via MVVM. For example, the same applies for columns.command.click of the Grid widget.

    We are also missing the razor function for setting html-attributes.

    Could you please specify where you want to set HTML attributes - to the ToolBar container or to the buttons inside it?

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Bert
    Bert avatar
    29 posts
    Member since:
    May 2012

    Posted 27 Aug 2014 in reply to Alexander Valchev Link to this post

    Hello Alexander,

    I do not understand what you mean with “configuration properties of the widgets cannot be bound via MVVM”. Can you clarify this? 

    My problem is as follow; I bind a button click to a method of a view model using the attribute ‘data-bind="click: handleButtonClick"’ which is working fine. But when the button is disabled it still calls the ‘handleButtonClick’ function which is a bug. When will this bug be fixed?

    We want to use Razor functions to set Html attributes for both the toolbar and the buttons. It would also be great that other widget can be added to the toolbar without the need of using templates e.g. a texbox or a combobox.

    Regards,
    Bert
  7. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 28 Aug 2014 Link to this post

    Hi Bert,

    What I meant to explain was that only the widget level events may be bound with the MVVM syntax like in the Dojo sample that I provided below. The button click handlers can't be accessed in this way.

    Your approach works because it binds the handler to the click DOM event, not the widget item click event. The ToolBar itself is not aware of the binding and therefore the enable functionality does not affect the binding in question.

    In the next service pack release we will add the feature you requested. You will be able to attach HTML attributes to the ToolBar container and to the buttons inside.
    Providing ability to add another widgets without a template is not in our immediate plans though.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Bert
    Bert avatar
    29 posts
    Member since:
    May 2012

    Posted 29 Aug 2014 in reply to Alexander Valchev Link to this post

    Hello Alexander,

    Many thanks for your help, it is clear now. We are looking forward for the next service release.
    I an afraid that you forgotten to provide the link to the Dojo sample. Can you please provide it since I am very interested in this example?

    Regards,
    Bert
  9. Answer
    Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 29 Aug 2014 Link to this post

    Hi Bert,

    this is the link Alexander referred to.

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready