Skip to Content
avatar image
Former Member

Cannot delete line from table with delete button

Hello Experts,

I have created a table with delete functionality as per the type delete of table as below.

Unfortunately the delete functionality is not working on clicking the delete button, below is the code I have written in JS base on information I got online.

I am not able to get value in variable oRowData from the method oModel.getData because of which it is not recognize the splice method.

I have searched some site and was able to get this code implementation only to delete row, also I observed the table was created using Java Script as per code online but in my case I have created through layout editor in XML, is the the problem here?

Request you help here..

Will reward accordingly.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • Apr 18, 2016 at 05:33 AM

    You can refer to the example here - JS Bin - Collaborative JavaScript Debugging

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 18, 2016 at 05:35 AM

    Hi K C,


    Your model must be having a name, try passing the model name

    var sPath = oItem.getBindingContext("yourModelName").getPath();
    var oModel = oTable.getModel("yourModelName");
    
    

    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2016 at 08:02 AM

    I have already referred the link JS Bin - Collaborative JavaScript Debugging but the problem there the table is created with JS but in my case with layout editor and because of that I am also not sure where to find ModelName as it is not defined anywhere while table creation.

    I am getting data from oData services

    Add comment
    10|10000 characters needed characters exceeded

    • Hello KC,

      here's how i did it:

      You have to give your table an ID. in my case "grTable".

      The ColumnListItem in my Table:

      <ColumnListItem press="onPositionsTableItemPress" type="Active" >

      And here's my onPositionsTableItemPress:

      oSelectedModel is the Model in your JSON which was clicked on. In your case it would be smth like

      .getModel().getData().splice(iSelectedItemIndex, 1):

      Regards

      Samuel

      TableXML.png (3.7 kB)
      GetTableModel.png (12.9 kB)
  • avatar image
    Former Member
    Apr 18, 2016 at 03:40 PM

    The problem is I am not getting data after calling getData method, it returns null

    Till getModel methods its working fine

    Below is the console output:

    Following is table structure

    My sPath value coming is sPath = "/IssueDetailSet(Memberid='0000000001',Bookid='0000000001')"


    Add comment
    10|10000 characters needed characters exceeded

    • KC,

      Try using getProperty() method:

      this.getView().byId("lineItemsList").getModel().getProperty("/IssueDetailSet");               // '/IssueDetailSet' will be your table items binding path
      

      Regards,

      Sai Vellanki.

  • Apr 18, 2016 at 05:22 PM

    from the binding context, you can also get the model

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2016 at 07:04 PM

    I am able to get model but not the data thru getData

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 19, 2016 at 06:52 AM

    here again it is returning undefined value 😔

    not sure where am I missing something


    Add comment
    10|10000 characters needed characters exceeded