on 12-09-2015 10:47 AM
Hello Experts,
I need your help in one of my requirement , where by default i have to show 5 blank rows following a particular template in my sapui5 table and clicking on a button say add new rows , five new empty rows should get inserted into the table.
A code snipet will be very helpful .
Thanks in advance.
Regards,
Vikash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vikash,
One of the method is:
Create a Local JSON Model with blank values . Bind it to you XML view. By default you will get 1 blank row assign.
Now write a code in controller to user setProperty() of model.
See the code below:
JSON Model:
{
"FamilyTableJson": [
{
"Relationship": "",
}
]
}
XML View:
<table Table xmlns="sap.m" id="idFamilyTable" inset="false" items="{/FamilyTableJson}" growing="true" wrapping="true" growingThreshold="3" growingScrollToLoad="false">
<columns>
<column hAlign="Center">
<Text text="Relationship" />
</column>
</columns>
<items>
<ColumnListItem>
<cells>
<Input xmlns="sap.m" visible="true" value="{Relationship}"
enabled="true" valueState="None" name="" placeholder="Relationship..."
editable="true" valueStateText="" showValueStateMessage="true"
textAlign="Left" type="Text" maxLength="17" showValueHelp="false"
showSuggestion="false" valueHelpOnly="false" filterSuggests="false">
</Input>
</cells>
</ColumnListItem>
</items>
</Table>
View Controller :
addTableRows : function()
{
for (var i = model.oData.FamilyTableJson.length; i<10; i++)
{
model.setProperty('/FamilyTableJson/' + model.oData.FamilyTableJson.length,
{
"Relationship": "",
});
};
}
Hope this will help you.
Regards,
Abhijeet
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.