Skip to Content

Issue in sap.m.Table

Hello Friends,

Using below code i am able to see the Rows into the sap.m.Table. when i change the code from "onAfterRendering" to "onInit: function()". its not working. i did debugging. i didn't understand. Can you please help me.

Controller.js

onAfterRendering: function() {
            var oModel = this.getView().getModel("ManualQuoteModelLineItems");
            this.getView().byId("lineItemsList1").setModel(oModel);
        }

View.XML

<Table class="myCustomText" id="lineItemsList1" mode="MultiSelect" items="{/manualQuoteDataLineItem}">
                <columns>
                    <Column demandPopin="true" hAlign="Center" id="articleColumn1" minScreenWidth="Tablet" popinDisplay="Inline">
                        <Text class="myCustomText" text="Article" textAlign="Center"/>
                    </Column>
                    <Column demandPopin="true" hAlign="Center" id="descriptionColumn1" minScreenWidth="Tablet" popinDisplay="Inline">
                        <Text class="myCustomText" text="Qty"/>
                    </Column>
                    <Column demandPopin="true" hAlign="Center" id="quantityColumn1" minScreenWidth="Tablet" popinDisplay="Inline">
                        <Text class="myCustomText" text="UoM"/>
                    </Column>
                    <Column demandPopin="true" hAlign="Center" id="grossWeightColumn1" minScreenWidth="Tablet" popinDisplay="Inline">
                        <Text class="myCustomText" text="Description"/>
                    </Column>
                </columns>
                <ColumnListItem visible="true" class="myCustomText" id="detailsListItem1">
                    <cells>                      
            <Input id="articaleId" value="{Article}" editable="true" maxLength="18" width="70%" class="sapMTableContentMargin" 
                    showValueHelp="true" valueHelpRequest="OnSelectArticle" submit="onEnterArticale" liveChange="onChangeArticle"/>
                
            <Input id="QtyId" value="{Qty}" editable="true" maxLength="10" width="40%" class="sapMTableContentMargin" 
                   submit="onEnterArticaleonQty" liveChange="onChangeQty" />       
            <Text id="UoMId" text="{UoM}" visible="true" width="20%" class="sapMTableContentMargin" />
            <Text id="descId" text="{DESC}" visible="true" width="100%" class="sapMTableContentMargin" />              
                    </cells>
                </ColumnListItem>
            </Table>

manifest.json

"models": {          
            "ManualQuoteModelLineItems": {
                "type": "sap.ui.model.json.JSONModel",
                "uri": "model/ManualQuoteLineItem.json"
            }         
        }

ManualQuoteLineItem.json

{
    "manualQuoteDataLineItem": [{
            "Article": "",
            "Qty": "",
            "UoM": "",
            "DESC": ""
        }, {
            "Article": "",
            "Qty": "",
            "UoM": "",
            "DESC": ""
            
        }
]
}       

Regards

Vijay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 23, 2016 at 02:32 AM

    Vijay,

    this is a common scenario when the table is not initialized yet, then sometimes you will see an error on the console. do you see one? maybe the model isn't available just yet. and by the same luck, it works on the after rendering event because by then, the model is now available.

    since you already have a model binding on the items of the table, and if you use an odata model, you do not need to execute the setModel function in the oninit funciton of the controller.

    most likely this is happenign on your json model from the json file in your project - temp fake data.

    hope this is helpful

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.