on 10-27-2015 2:32 PM
Hello expert,
I have a table which have values from my local. I can add values and delete values also but I want to do edit/update of selected value. I can get the values to my Dialog's Inputs but when I press the button the values are adding like new value to my table (like my add function)
When I select a row I want to edit this. I saw some CRUD examples but I dont need these operations from SAP. I just want to see my local values and edit them.
If you have any example or suggestion, pls send me I really need this for my project.
Edit: "JS Bin - Collaborative JavaScript Debugging" this example is so close to my view. I just need Edit function.
Thanks,
Ogulcan G.
Hey Ogulcan
First change your selection mode of your table to Single, like this:
selectionMode : sap.ui.table.SelectionMode.Single,
Then it is clearer that a row can be selected
Then add a function to be called when one selects a row and add it to the rowSelect event in your table, for example
rowSelect:function(event){selectRow()}
Row select should go ahead and add the info in the table to the edit boxes. Maybe add an hidden or uneditable edit box for the id. Just say if you are not sure how to do that. You will need the id of the row that was selected to edit or remove that row from the dataset. So either store it in a field or check if you can find the id with the table's available functions.
Then when add or delete is pressed search for the id you stored in the dataset to determine what the index is , if "2" is the selected id, do this:
var elementPos = mdData.Employees.map(function(x) {return x.id; }).indexOf("2");
This returns the index.
To delete you can do this:
mdData.Employees.splice(elementPos,elementPos + 1);
To edit you can do this:
mdData.Employees[elementPos] = {firstName:"Tian", lastName:"saran",age:"25",address:"Salem", id: "1"};
or to just edit firstname for example:
mdData.Employees[elementPos].firstName = "Somon"
oModel.setData(mdData);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ogulcan,
Will this help?
JS Bin - Collaborative JavaScript Debugging
Go to First name or lastname line item ---> edit/update is working good
Thanks,
KA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.