on 09-05-2017 9:52 AM
Hi Guys,
what will be the best way to check if the row is already exists in UI5 table before insetion a new record in ui5 table.
I thought i will check the record which i'm going to insert by doing oModel.Read and if the record exists then give message to user if not insert a new record.
Can you share your views or the methods?
Thanks,
Anurag
Hi Anurag,
My suggestion is to use model to check the duplicate which is associate with the table.
We have array.map function in javascript.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
oTableModel = this.getModel("TableModel");
oTableModel.getProperty("/Items");
var iIndex = oTableModel.map(function(img) {
return img.id;
}).indexOf(pass_inserted_Id);
It will return true, if that model already contains same id.
Using this you can avoid duplicated in your table.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can check with the key of your entry. If your table is bound to OData model, then you can check if the entry exist with that code :
var entry = myOdataModel.getProperty("/myService(key1='value1',key2='value2')");
The entry variable will tell you if there is something or not.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For the data in a view control ex: table, we can either check for the data through the control id or through the model bound to the control.
I would suggest, checking with the model data, as based on the entries of the model the rows are created in the control.
If the model is empty, then there are no rows in the table.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.