Forum Stats

  • 3,872,120 Users
  • 2,266,382 Discussions
  • 7,911,052 Comments

Discussions

Question About Javascript in Interactive Grid

User_JNHXJ
User_JNHXJ Member Posts: 16 Green Ribbon
edited Sep 18, 2022 8:57AM in APEX Discussions

Hello im new to apex,and currently still learning about the usage of java script in apex.


yesterday i found this code

var a;

a=this.data.model.getValue(this.data.selectedRecords[0],"FIRST_NAME");

apex.item("P17_ZZZ").setValue(a);

this code is used to get "FIRST_NAME" column value from a selected record in Interactive grid and pass it into an item called P17_ZZZ.

my question is

what is ".data.model" and ".data" in this code means? because i cant find a single document which contain information about ".data.model" or ".data" and based on my knowledge i can assume this code is only works for interactive grid report.

Best Answer

  • Pierre Yotti
    Pierre Yotti Member Posts: 4,046 Bronze Crown
    edited Sep 18, 2022 2:11PM Answer ✓

    Hello User_JNHXJ,

    this.data is not just related to the interactive grid. it depends on the event. The event can be an interactive grid event or a page item event and so on.


    The data returned by this.data depends on the event handler. In the case of the IG (selection change event) this.data, return a model object and selectedRecord Array.


    • Try this for example in the Browser Console. Here the event is the interactivegridselectionchange
    • emp is the Grid static ID
    $("#emp").on("interactivegridselectionchange", function(event, data) {
     console.log(data)
    });
    
    • And then select a row in The Grid, you will get an object as result with model and selectedRecord as attributes


    Check out some interactive grid events here


    Thanks


    Pierre

Answers

  • Pierre Yotti
    Pierre Yotti Member Posts: 4,046 Bronze Crown

    Hello User_JNHXJ,

    this.data is optional extra data that can be passed by any event handler.

    this.data is retrieved when the interactive grid row is selected. To get this.data, you should create dynamic action on selection change of the GRID.


    How to get this.data in Interactive Grid?

    • Create a dynamic action on Selection Change [Interactive Grid]
    • Selection Type: Region
    • Region : Choose the name of the region that will trigger the dynamic action. This is an "Interactive Grid" area in our example.
    • Action: Execute Javascript Code
    • Code : Add your code defined above


    Hope it will help you.


    Pierre

  • User_JNHXJ
    User_JNHXJ Member Posts: 16 Green Ribbon

    thanks for answering Pierre , but i already know how to implement the code inside the apps.

    what i dont know is the meaning of the code

    is "this.data.model" refer to the interactive grid while "this.data" only refer to the interactive grid data?

    thats what i want to know

  • Pierre Yotti
    Pierre Yotti Member Posts: 4,046 Bronze Crown
    edited Sep 18, 2022 2:11PM Answer ✓

    Hello User_JNHXJ,

    this.data is not just related to the interactive grid. it depends on the event. The event can be an interactive grid event or a page item event and so on.


    The data returned by this.data depends on the event handler. In the case of the IG (selection change event) this.data, return a model object and selectedRecord Array.


    • Try this for example in the Browser Console. Here the event is the interactivegridselectionchange
    • emp is the Grid static ID
    $("#emp").on("interactivegridselectionchange", function(event, data) {
     console.log(data)
    });
    
    • And then select a row in The Grid, you will get an object as result with model and selectedRecord as attributes


    Check out some interactive grid events here


    Thanks


    Pierre