cancel
Showing results for 
Search instead for 
Did you mean: 

edit a row in sapui5 smartTable

ashok_dhayalaraj
Explorer
0 Kudos

Hi,

I would like to know how I can edit a single row in sapui5 smartTable

former_member182862
Active Contributor
0 Kudos

HI Ashok

Can you kindly elaborate? It is hard to understand what you intend to do with only one sentence.

And what have you tried? And what does not work?

Thanks

Dennis (Moderator)

ashok_dhayalaraj
Explorer

Hi Dennis,

I have inserted a smart table with a editToggle button and trying to select a row to edit the same. As I can see, there is a method where the event for the same will get triggered. But I do not find any method to retrieve the data what I have selected to change the row alone. I tried using the same way that I use to edit a Grid Table, but those methods are not available in the Smart Table. I also saw in the Fiori guidelines that Smart Tables are used to display simple tables for display. I have also placed my code below for your reference, which I have used for the grid table. Pls help

	Code for changing a row property in Grid Table	
		fGapChange: function(oEvent) {
					//This code was generated by the layout editor.
					var oPage = this.getView().byId("idGapPage");
					oPage.setShowFooter(true);
					var oTable = this.getView().byId("idGapTable");
					var aindex = oTable.getSelectedIndex();
					var selectedRow = oTable.getRows()[aindex];
					//			static aValues;
					//			aValues = selectedRow.getBindingContext();
					for (var i = 0; i < 3; i++) {
						selectedRow.getCells()[i].setProperty("editable", true);
						//			aValues[i] = selectedRow.getCells()[i].getProperty("value");


					}
				}


View Code:

	<Page id="idGapPage" title="Gap Master" showNavButton="true" navButtonPress="fGoBackFromGapMaster" showFooter= "false">
				<content>
				    <Button text="Create" width="100px" id="bCreate" icon="sap-icon://create" press="fGoToGapCreate"/>
				    <Button text="Edit" width="100px" id="bChange" icon="sap-icon://edit" press="fGapChange"/>
				    <Button text="Delete" width="100px" id="bDelete" icon="sap-icon://delete" press="fGoToGapDelete"/>
<!--				    	<smartFilterBar:SmartFilterBar 
		id="smartFilterBar"
		entityType="Product">
		<smartFilterBar:controlConfiguration>
			<smartFilterBar:ControlConfiguration
				key="Category" visibleInAdvancedArea="true"
				preventInitialDataFetchInValueHelpDialog="false">
			</smartFilterBar:ControlConfiguration>
		</smartFilterBar:controlConfiguration>
	</smartFilterBar:SmartFilterBar>-->
<!--	<smartTable:SmartTable 
		id="idGapTable"
		tableType="Table" 
		editable="false"
		entitySet="GapMasterSet" 
		useVariantManagement="false"
		useTablePersonalisation="true"
		editTogglable="true"
		header="Gaps" 
		showRowCount="true"
		useExportToExcel="false"
		app:useSmartField="true"
		enableAutoBinding="true">
	</smartTable:SmartTable>
    </content>-->
				    	
	<table:Table id="idGapTable"
		rows= "{/GapMasterSet}"
		selectionMode= "Single"
		>
	<table:columns>
		<table:Column>
			<Label text = "Project ID"/>
						<table:template>
							<Input value="{ZprojId}" editable= "false"/>
						</table:template>	
		</table:Column>
		<table:Column>
			<Label text = "Gap ID"/>
						<table:template>
							<Input value="{ZgapNo}" editable= "false"/>
						</table:template>
		</table:Column>
		<table:Column>
			<Text text = "Description"/>
						<table:template>
							<Input value="{ZgapName}" editable= "false"/>
						</table:template>
		</table:Column>
	</table:columns>	
	</table:Table>
			</content>
			<footer>
				<Toolbar>
					<ToolbarSpacer/>
					<Button text="Save"  width="100px" type= "Accept" id="bSave" icon="sap-icon://save" press="fGapSave"/>
				    <Button text="Cancel" width="100px" type= "Reject" id="bCancel" icon="sap-icon://cancel" press="fGapCancel"/>
				</Toolbar>
			</footer>
			</Page>

Accepted Solutions (0)

Answers (1)

Answers (1)

hi Ashok,

Have you got solution for this? If yes Could you please post or share with us.. it will be very help full for us