Forum Stats

  • 3,826,391 Users
  • 2,260,640 Discussions
  • 7,896,927 Comments

Discussions

Expression binding in nested oj-list-view?

Venkata Rahul S
Venkata Rahul S Member Posts: 37 Blue Ribbon

I have a pair of entities with a 1:n relation. For example an OrderHeader and an OrderLine. I use a REST service to provide me data for several orders and the lines for each order.

I intend to build a list of collapsible orders, with oj-collapsible and have no problems with that. Now for each order, I am using a oj-navigation-list with a template to get data from each line and show the lines as navigable items. For the navigation list, how do I create the dataProvider?

I tried this:

<oj-navigation-list id="activitiesList" drill-mode="none" data="[[{

new ArrayDataProvider(order.data.lines, {keyAttributes:'code'});

}()]]">

<template slot="itemTemplate" data-oj-as="line">

................................................

</template>

</oj-navigation-list>

I cannot get past this because the framework cannot parse the expression inside.

What mistake am I making? Is expression binding even allowed? What is the correct method?

Please help..


Rahul

Tagged:

Best Answer

  • Venkata Rahul S
    Venkata Rahul S Member Posts: 37 Blue Ribbon

    I achieved what I needed with a function in place of an inline call. I just created a method:


    getOrderLineProvider(linesArrayVar : Array<OrderLines>){

    //...............return new ArrayDataProvider from the linesArrayVar with appropriate keys

    }

    and in my nav list tag,

    data=[[getOrderLineProvider(order.data.lines)]]

    I guess inline syntax parser does not allow a slightly complicated IIFE

Answers

  • Venkata Rahul S
    Venkata Rahul S Member Posts: 37 Blue Ribbon

    I achieved what I needed with a function in place of an inline call. I just created a method:


    getOrderLineProvider(linesArrayVar : Array<OrderLines>){

    //...............return new ArrayDataProvider from the linesArrayVar with appropriate keys

    }

    and in my nav list tag,

    data=[[getOrderLineProvider(order.data.lines)]]

    I guess inline syntax parser does not allow a slightly complicated IIFE

  • I believe you do not need to pass in the argument either. It should be available as part of one of the three arguments passed to all methods. (event, data, context)

  • Venkata Rahul S
    Venkata Rahul S Member Posts: 37 Blue Ribbon

    Hmm.. Nope.. this is not an event. This is merely a method to procure the DataPRovider from the current Order data. Given this, is'nt the parameter still required?

    If it is not, can you please provide a pointer to a similiar place in the cookbook? Or provide the syntax in one of these comments please?

  • Venkata Rahul S
    Venkata Rahul S Member Posts: 37 Blue Ribbon

    And BTW, I cannot still succeed with the original attempt to do this inline creation of the DataProvider. Is that even possible?.

  • John 'JB' Brock-Oracle
    John 'JB' Brock-Oracle Posts: 2,793 Employee
    edited May 6, 2022 2:39PM

    I would not recommend doing inline coding like that. You could easily run into Content Security Policy issues when you do this kind of thing. Use the separation of HTML/JavaScript and add the DataProvider definition in the viewModel.

    I honestly don't know if it's suppose to work or not. I've never seen anyone try it before.

  • Venkata Rahul S
    Venkata Rahul S Member Posts: 37 Blue Ribbon

    I can see your point. My initial need though is met. So no point taking this further to an accurate yes/no solution.