I'm trying to image how can I delete a table row (core data or sqlite) using a Table View.
Well, I can do it with PHP using a hidden Id and then, looking for the matching Id in the data table to delete it.
In C# with the Entity Framework I can delete a table row with a simple DeleteObject instruction that will automatically remove it from the data table.
How can I do the same thing with iOS SDK? How can I tell the SDK to get the selected item id, find it in the data table and delete it?
Thank you,
Regards.
Use objectAtIndex:indexPath.row from within the didCommitEditingStyle method. This is assuming you have some sort of array that is being used to populate your TableView. This will return the object in your array that corresponds to the row that the user wishes to delete.
Related
I have a SAP UI5 V2 odata model with a two way binding to a table and to a form.
The table is displaying all records, and when clicking on a record, I am using setBindingContext to bind the selected table record to the form for editing. When typing in the form, the values dynamically update in the table (because of the two way binding). model.submitChanges() writes the change back to the server.
So displaying the list, and editing records in the list are working just fine.
Now for the problem How to create records with the same form?
I also want to use the same form for adding new records, but I cannot figure out how to unbind the form from a previously selected record, or otherwise create a new blank entry in the data model to be sent to the server.
All of the tutorials I have been able to find on doing UI5 Odata CRUD operations don't really address this problem.
I discovered this example in the documentation which pointed me in the correct direction.
In summary, you use the oModel.createEntry method to create a new entry in the oData Model. You then have to bind this new entry to your form with setBindingContext - this is the part I was missing.
I was wondering if there is any way to populate a table using two different records. My records have the same primary keys, but when I am adding the specific fields to my grid I have this error:
More than one data (key) in one scroll.
I tried to make a Control view field in my primary record, and then refer the new record fields as relative fields but in this case the data is not populating in my grid. Any help or hint will be much appreciated.
I've only done this where the 2nd record is a Derived/Work record.
Can you create a view that combines both records, and put the view in the grid? FYI, peoplesoft let's you update the data in a view, which is not typical in an oracle db system.
Ok guys finally after all discussion, and much try rounds I figured out how to do this.
You need to add a draw a grid beside your old grid and populate it with a new record, which has dynamic view (dynamic sql). The only important case there, is you need to make sure the order of your fields in your records, are in the same order of your fields in the SELECT statement of your sql. Otherwise you will see
an SQL error
.
Try to make a field as display control field which is acting as primary key for its native table and as Foreign key for some other record.. A field needs to be made related if is being fetched from some other record... that is from the record which is not under current consideration. I think this way one can fetch data into grid or scroll respectively from multiple records.
In my application i added all data into table view. Then I need entire row by using search operation.
Searching is based upon any data like search by RegisterNo or search by Name. By entering RegisterNo it Should display entire row related to RegisterNo.
To do search operation in a TableView, what I've done is to add a notion of filters.
For example if you want to filter by name, each time your name query change, you filter all your data and let on the table only those who match your query.
You always keep the full data to execute your query on it, but to display it use an other list.
with that I'm able to have lot of filters at the same moment and my view refresh in real time
I have a column and I would like to edit some of its rows. The problem is that the table is a view so I cannot edit the rows. How would I proceed to solve this problem?
SQLite doesn't let you update views. But it does allow triggers on views. So you can write an INSTEAD OF UPDATE trigger that makes the appropriate modifications to the underlying table.
As dan04 pointed out, you can use triggers to update views (like in most other databases). For sqlite, see http://www.sqlite.org/lang_createtrigger.html#instead_of_trigger
Example with a view called "myview", containing a table "my_t2"
CREATE TRIGGER myview_update INSTEAD OF UPDATE ON myview
BEGIN
UPDATE my_t2 SET field1 = new.field1, field2 = new.field2 WHERE my_t2.key = old.key;
END
If it's a view, it's not a table. The data for the view is drawn from one or more other tables. Edit the underlying table and when you examine the data in the view it will reflect the changes you made.
A SQL View is a virtual table, which is based on SQL SELECT query. Essentially a view is very close to a real database table (it has columns and rows just like a regular table), except for the fact that the real tables store data, while the views don’t. The view’s data is generated dynamically when the view is referenced. A view references one or more existing database tables or other views. In effect every view is a filter of the table data referenced in it and this filter can restrict both the columns and the rows of the referenced tables.
If you wish to modify the data in your table, you cannot do so with a view. SQL Views are always read-only. If you want to modify your table outside of the View, then use something like an UPDATE or ALTER TABLE statement.
I implemented paging for one of my GridViews. Now I want that all checked boxes(which are kept in first column of GridView) to be inserted to Database. How can I achieve this? Please let me know.
I want to know how can I save the checked rows to the data table, and then re-bind to this temporary data table to grid view
If some body navigate back and uncheck check box for the row then how can i remove it again from the temporary datatable
Using a gridview and DataAdapters you can achieve this. Read more about updating data with DataAdapters here. To quote Microsoft on the use of DataAdapters:
You can use a data adapter to perform
the following operations:
Retrieve rows from a data store into
corresponding data tables within the
dataset.
To retrieve rows into a dataset, use
the Fill method on a data adapter
object (SqlDataAdapter,
OleDbDataAdapter, OdbcDataAdapter, or
OracleDataAdapter). When you invoke
the Fill method, it transmits an SQL
SELECT statement to the data store.
Transmit changes made to a dataset
table to the corresponding data store.
To transmit a dataset table of the
dataset to the data store, use the
adapter's Update method. When you
invoke the method, it executes
whatever SQL INSERT, UPDATE or DELETE
statements are needed, depending on
whether the affected record is new,
changed, or deleted.