Cannot bind the attribute to the input field as a object.

3 posts, 1 answers
  1. Rasika
    Rasika avatar
    18 posts
    Member since:
    Jul 2015

    Posted 08 Sep 2015 Link to this post

    I have a view model object . Here it is.

    a{ b : {name : "p",id : "q", type : "text"} }

    Here is my view.

    <table data-template="myTemplate" data-bind="source: a"></table>

     <script type="text/x-kendo-template" id="leadFieldsTemplate">

        <tr>

              <td>

                      <input class="k-input k-textbox" data-bind=" attr: b  " />

              </td>

        </tr>

    </script>​

    But above method not working. 

    Then I change it to like this

     <script type="text/x-kendo-template" id="leadFieldsTemplate">
        <tr>
              <td>
                      <input class="k-input k-textbox" data-bind=" attr: {name : b.name , id : b.id , type : b.type } " />
              </td>
        </tr>
    </script>​​

    Then it is working. So why the first method not working ???

    In all time do I have to mentioned the attributes in the input field before bind them ??

     

    Thank you

  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 11 Sep 2015 Link to this post

    Hi Rasika,

    There are a few things:
    1. The table's data-template points to "myTemplate", however the id of the provided template is "leadFieldsTemplate"
    2. Source binding expects an array, not an object
    3. Attr binding expects each attribute to be explicitly specified. Passing a field containing key/value pairs is not supported


    Regards,
    Alexander Popov
    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. Rasika
    Rasika avatar
    18 posts
    Member since:
    Jul 2015

    Posted 11 Sep 2015 Link to this post

    Thank you very much for your help
Back to Top