how do observablearray dataItem add property

4 posts, 0 answers
  1. Jason
    Jason avatar
    9 posts
    Member since:
    Sep 2013

    Posted 23 Mar 2014 Link to this post

    Dear Sir

    I have a observablearray from a children property of remote service, which is a purchase order. You could image it as master-child structure.

    after get observablearray of order details, I bind it to a grid. It works well.

    But when I try to add a dependency property to this observablearray to calcuate ( quantity * unit price.) But it couldn't work.

     I know it could be done by bind "change" event and it works well. But I wonder if it can be done by dependency property or method.

    there is the sample: http://jsfiddle.net/R6KSs/2/

    Thank you very much.

    Jason
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 24 Mar 2014 Link to this post

    Hi Jason,

    In your case the easiest solution is to use a template to calculate the "Amount" value.
    {
       title: "Amount",
       template: "#: Qty * UnitPrice #"
    },

    For your convenience I updated your sample: http://jsfiddle.net/R6KSs/4/
    Also please note that it is not needed to wrap the data array as Observable. The DataSource will automatically do that.

    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. Jason
    Jason avatar
    9 posts
    Member since:
    Sep 2013

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

    Dear Alexander

    thank you for your kind help. But
    1. it will miss the format defined on "format" property.
    2. when add new, it will be error on "qty" isn't defined. 
    3. I still need to work on the change event because there is a sum property on the master which be = sum ( the detail's amount.)

    Frankly, there will be more complex logic needs to get help with dependency property, like complex conditional format the row, cell or column. 

    is there any way to create a method or property into it?

    Thank you very much.

    Jason

  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 27 Mar 2014 Link to this post

    Hello Jason,

    In case you insist using computed fields please follow the approach described here.
    For your convenience I updated your sample (and Kendo UI version it is using): http://jsbin.com/pehakaca/2/edit

    Regards,
    Alexander Valchev
    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