Skip to Content
avatar image
Former Member

Get value column in row table SAPUI5

<code>  deleteButton2 :function(){var oTable =this.getView().byId("tableKelompokPeserta");

       oTable.attachRowSelectionChange(function(oEvent){var currentRowContext = oEvent.getParameter("rowContext");var selData = extModel.getProperty("template", currentRowContext);
           console.log(selData);
           sap.m.MessageToast.show(currentRowContext);});},

   onInit :function()<br>{<br>var router = sap.ui.core.UIComponent.getRouterFor(this);<br>var uri ="http://172.16.50.202:8081/id/co/taspen/joinDevelopment/modules/tks_mantab/service.xsjs?cmd=get";<br>var jsonMod =new sap.ui.model.json.JSONModel(uri,true);<br>var oTable =this.getView().byId("tableKelompokPeserta");
        oTable.setModel(jsonMod);var oColumn1  =new sap.ui.table.Column({
            label :new sap.ui.commons.Label({
                text:"KODE KELOMPOK", 
                textAlign :"Center"}),template:new sap.ui.commons.TextField().bindProperty("value","KODE_KELOMPOK"), 
            sortProperty :"KODE_KELOMPOK",
            filterProperty :"KODE_KELOMPOK"});var oColumn2  =new sap.ui.table.Column({
            label :new sap.ui.commons.Label({
                text:"NAMA", 
                textAlign :"Center"}),template:new sap.ui.commons.TextField().bindProperty("value","NAMA"),   
            sortProperty :"NAMA",
            filterProperty :"NAMA"});var oColumn3  =new sap.ui.table.Column({
            label :new sap.ui.commons.Label({
                text:"MINIMAL USIA MASUK", 
                textAlign :"Center"}),template:new sap.ui.commons.TextField().bindProperty("value","MINIMAL_USIA_MASUK"),     
            sortProperty :"MINIMAL_USIA_MASUK",
            filterProperty :"MINIMAL_USIA_MASUK"});var oColumn4  =new sap.ui.table.Column({
            label :new sap.ui.commons.Label({
                text:"MAKSIMAL USIA MASUK", 
                textAlign :"Center"}),template:new sap.ui.commons.TextField().bindProperty("value","MAKSIMAL_USIA_MASUK"),
            sortProperty :"MAKSIMAL_USIA_MASUK",
            filterProperty :"MAKSIMAL_USIA_MASUK"});var oColumn5  =new sap.ui.table.Column({
            label :new sap.ui.commons.Label({
                text:"TERUSAN", 
                textAlign :"Center"}),template:new sap.ui.commons.TextField().bindProperty("value","TERUSAN"),                
            sortProperty :"TERUSAN",
            filterProperty :"TERUSAN"});var oColumn6 =new sap.ui.table.Column({
            label :"ACTION",template:new sap.ui.commons.Button({
                icon :"sap-icon://edit",
                tooltip :"{KODE_KELOMPOK}",
                press :function(){var id =this.getTooltip();}})});         

        oTable.addColumn(oColumn1);
        oTable.addColumn(oColumn2);
        oTable.addColumn(oColumn3);
        oTable.addColumn(oColumn4);
        oTable.addColumn(oColumn5);
        oTable.addColumn(oColumn6);
        oTable.bindRows("/d/results");}<br>
<code>I want to delete data by row in my table sapui5 but have an error. I have table with id name "tableKelompokPeserta".
I have 6 columns and I want to get "KODE_KELOMPOK" column selected row (single selection only). I want when click deletebutton2, I get "KODE_KELOMPOK" (from oColumn1). and how to disable multiple row in sapui5? Thank you.
Regards,
Bobby



<br>
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 08, 2017 at 10:14 PM

    hi Bobby -

    there are two answers to your questions:

    1) how to disable multiple selection on the table... look into the selectionMode property https://sapui5.hana.ondemand.com/#/api/sap.ui.table.SelectionMode

    here is an example with the sap.m.Table as well https://sapui5.hana.ondemand.com/#/sample/sap.ui.table.sample.Selection/preview

    2) how to delete rows in the table - based on your data model, you can identify the current item that belongs to the row (item in array) that is bound to your table then you can remove it and either update your model property or set it again to the new list(array) that doesnt contain the row/item any more

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 08, 2017 at 10:16 PM

    one good approach would be to create a custom data attribute/property to identify the row/item in context and add it to the button using the custom data attribute: https://sapui5.hana.ondemand.com/#/api/sap.ui.core.CustomData

    then on button press event / capture the identified and remove it from your model

    Add comment
    10|10000 characters needed characters exceeded