Skip to Content
0

edit a row in sapui5 smartTable

Jul 06, 2017 at 11:50 PM

148

avatar image
Former Member

Hi,

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

10 |10000 characters needed characters left characters exceeded
Former Member

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)

0
Former Member

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>

0
* Please Login or Register to Answer, Follow or Comment.

0 Answers