I have a question regarding views on postgresql.
We have two views on two different schemas. One called "first" and the other one is called "second".
We need the view "first" to be created and always have the same content as the view "second". When i say content i mean the query that constructed the view and not the result of the view.
In summary: query of view first changes->query of view second changes
Is something like this possible?
If you need more details you can ask me.
Thanks in advance!
Related
I am working with Swift 2.0 using XCode 7.3.
I currently have 2-Navigation-View-Controllers(NAV1 & NAV2) . Each of which that has their own separate Table-View-Controllers(TAB1 & TAB2) with corresponding Tables (TABLE1 & TABLE2).
TABLE1 has a separate child tables (TABLE1A...TABLE1Z) based on data.
The second table (TABLE2) has a way of changing data shared by table1 and its child tables (TABLE1 & TABLE1A...TABLE1Z) via a shared, singleton class. The 2-Navigation-View-Controllers(NAV1 & NAV2) are each Modals of a Tab-Bar-Controller (TAB_MAIN). The singelton class is accessible through any Controller and is a means of data-sharing.
TAB_MAIN
-NAV1
--TABLE1 (SINGLETON)
----TABLE1A (SINGELTON)
----... [potential for multiple sub-modals/tables](SINGLETON)
----TABLE1Z (SINGLETON)
-NAV2
--TABLE2 (SINGLETON)
What I would like is the following:
Changes to the Singleton data made in TABLE2, to update the data in TABLE1 and all its child modals immediately.
Note: Currently this is working by updating the data in the singleton class through function calls; i.e. objectClass.changeData()
Once the data is updated, via selection of a specific row in TABLE2, I would like to :
(a) change the currently selected tab to the first tab-view-controller
NAV1. Note this currently works via:
tabBarController?.selectedIndex = 1
(b) Update the displayed data in the table(s) for all the tables attached to the parent nav-controller for the first tab (NAV1).
(c) Unwind to the first tableView of the first tab (NAV1).
Currently what happens is, changes in NAV2->TABLE2 update the data and change the currently selected tab to whatever tableView NAV1 was left at, without changing the data.
Only by going to the parent (NAV1->TABLE1) of all sub-tables (i.e. TABLE1A...TABLE1Z, TABLE1AA, etc) does the data get reset and then by selecting the tableViews and drilling down does the data display in the child tables get properly updated.
I would like to 'unwind' to the top-most tableView of the first NAV1 controller from within the second NAV2 controller, or, failing that, update the information automatically on switching from NAV2->TABLE2 to any currently drilled-down NAV1->TABLEX.
Try use observer in NSNotifcationCenter in your NAV2-Table2. Add the observer in viewDidLoad
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Table2ViewController.updateTable(_:)), name:"NotificationUpdateTable2", object: nil)
then call to update using postNotificationName after perform update in another view controller. this will reflect changes in table2
NSNotificationCenter.defaultCenter().postNotificationName("NotificationUpdateTable2", object: objectData)
remember to put comments to easier track changes since the observer can be triggered anywhere
I have a view controller and a table view contoller. In my view controller, I have 6 different buttons which when pressed should each load different arrays table view.
I made this diagram:
How should I proceed?
The solutions to this can range from very simple to more involved depending on how different the contents and behaviours are between your 6 arrays.
Simplest: All six arrays have the same structure and behave exactly the same in the table view.
--> Define a "current" array variable for your table view data source and copy the content of the selected array to it when a button is pressed. Then call reloadData.
A little more complex: All six arrays have the same structure but must show different content in the table view.
--> Use "Current" array variable as above but define multiple prototype cells in the table view. Maintain an internal variable in your view controller to determine which button is currently selected. In the getCellForRowAtIndexPath method, use your internal variable in a switch statement to perform the appropriate dequeuing and mapping of cell contents.
Most complex: Arrays have different structures and must show different content/behaviour.
---> Define a class for each array and implement the datasource and delegate methods specific to the structure and cell content/behaviour that you need. In your buttons, switch the table view's delegate to the corresponding class. (this will help keep the specifics of each array type cleanly separated)
I have a main form called fm_Main. This fm_Main contains an embedded view which has 2 actions: Add & Delete. When I click Add is opening another form called fm_Second and here I can add some fields which will be displayed on the embedded_view on fm_Main.
The problem is: Let say I have 3 documents. All of them contains an empty embedded view. If I add some value fields in one document into the embedded view and then I save that document, all the 3 documents contains that values into the embedded. It should be: just one of them should cotain because I modified only one, the 2 of them shoudn't have that values displayed in the embedded view. Thank you!
PS: Also if I saved one document with an entry into the embedded view. When I want to create another new document, in the embedded view there exists the last entry from the last document. I want to be empty!
You must filter the embedded view to only show the entries related to the currently open main document.
Most programmers would use the UniversalID of the main document, it can be automatically populated into the entries you create.
One thing to think about is that you may want to store the Universal ID in a computed when composed field on teh main document. If you get a replication error in the future, the Universal ID may change, and you will not be able to get to the entries in the embedded view.
I been doing exactly this in several large Notes databases, works perfectly fine.
Expanding on Karl-Henry's suggestion, you should make into a categorized view and use the Show Single Category feature of the embedded view. I might suggest using the #Unique function instead of the UNID to relate the Main and Second documents, but that's a matter of preference. In either case, you have to make sure that the value inherits down into a field in the Second docs, and you can use that field as the category for the view.
Are there any built-in tools to sorting cells in a tableview by content title etc ?
No, it's assumed that whatever data model you are maintaining behind the table view can be sorted, or accessed in the appropriate order for displaying. You'll want to study here and here.
Im making a iPhone app which includes a list of sports teams.
RootViewController lists all the teams in a table view.
When I click a row I want to load up a TeamViewController, which just shows the record for a single team.
The catch is Im wanting to display that single teams details in the Grouped Table View Style.
This is causing me endless issues.
I just can't seem to work out where I draw on the objects I need from. eg Do I need to use NSFetchedResultsController.
Ive implemented core data and can see example of what to do from the AppDelegate and RootViewController but which bits to replicate and which parts I just call in in my new TeamViewController have me stumped.
To setup cellForRowAtIndexPath in TeamViewController what are the main steps I need to go through so that I can pull in the single selected record and be able to manipulate it and also how do I go about laying out my Grouped Table View for that record.
More broadly what Im not seeming to get is which bits are carried forward in each new ViewController so I can make my navigation app have many pages, with each record drilling in to give the next pages view.
If this is a bit confused just ask me more questions and I'll clarify.
It sounds like your using a Master-Detail pattern wherein you have a list of teams in the master tableview and then detail view that shows the details of each team. You just have one entity "Team."
For the master tableview, you would just use a NSFetchedResultsController to fetch and order the list of teams.
The detail view controller should have a property that holds a reference to a single instance of the Team class (or a generic managed object if you don't have a custom subclass.)
In the master view's didSelectCellAtIndexPath: method, you set the detail view's team property to the Team instance at that indexPath in the FRC before you push the detail view onto the navigation controller.
You configure the grouped table in the detail view by using a simple switch statement with one case for each row in the table which in turn corresponds with a property/value of the Team class/entity. Since the table displays the property/named-values of a class and not a variable list of many objects, the number of rows and sections is always fixed. If you want multiple groups, you can nest switch statements. The outer switch is for sections and the inner switch for rows.
#property (nonatomic,retain) Team *currentTeam;
...
- (void) configureCell:(UITableViewCell *) cell forIndexPath:(NSIndexPath *) indexPath{
switch (indexPath.section) {
case 0: // first section
switch (indexPath.row) {
case 0:
cell.textLabel.text=currentTeam.name
break;
case 1:
cell.textLabel.text=currentTeam.homeCity
break;
case 2:
// and so on
break;
case 1: //second section
//...
break;
}
break;
default:
break;
}
}
There isn't enough space or time to answer your question fully in this comment field, as such an answer would need to cover Core Data, but also pushing a new view controller onto a navigation controller stack, and how to work with UITableView and a table view controller. You may want to go through Apple's Core Data "Books" tutorial, which may help you with some of this.
The following is my own notes and to hopefully help anyone who is looking to answer the question I asked in the title.
To answer the question of 'How to select and show a single record in Grouped Table View Format'
more generally I see that two things so far are relevant.
The contents of an individual cell are shown at 'cellForRowAtIndexPath of the DetailViewController' (TeamViewContoller in my case).
You can include a switch statement in cellForRowAtIndexPath which goes through IndexPath.row and enables you to output a single table row in one page filling out a table view or grouped table view. See this page of the Books example app that Alex so kindly mentioned in his answer.
(http://developer.apple.com/iphone/library/samplecode/CoreDataBooks/Listings/Classes_DetailViewController_m.html)
How does the new page get it's data?
It's like this.
The current view controller on top of the navigation-controller stack creates the next view controller in the sequence and, before it pushes it onto the stack, sets the data this view controller, acting as data source, needs to populate its table view.
Apple's reference here is useful:
http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/TableView_iPhone/TableViewAndDataModel/TableViewAndDataModel.html