UA-17470720-3

Jump to content


Photo
- - - - -

Can one tableview with a list open another linked tableview with a list in STV?

models sections view-controllers

  • Please log in to reply
28 replies to this topic

#1 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 01 January 2016 - 10:32 AM

First, I’m not sure on what Forum to post this topic. It’s about ViewControllers, Sections and Datamodel. Please correct me if I’ve chosen the wrong Forum!

 
## My objective:
- A tableview of accounts with balances (raw balance).
- Open another tableview of transactions for that account by tapping on it.
 
## Workflow
- STV samples workflow normally is: list -> form -> list
- I need however: list -> list -> form
 
## Questions
1. Is this possible in STV now? If yes, how?
2. If not, can it be made possible?
 
## Illustration
For instance, below is the primary tableview, raw balance :
 
| Account | Balance |
| Cash      | 200 >     |
| Credit     | 200 >    |
| Sales      | -400 >   |
 
When tapping on Cash this second tableview, account history, opens:
 
< Account: Cash Balance 200
 
| # | Date         | Amount  |
| 1 | 1-1-2016 | 50           |
| 2 | 1-1-2016 | 60           |
| 3 | 1-1-2016 | 90           |

  • VewSnignineroqn likes this

#2 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 01 January 2016 - 03:36 PM

use the cell action for didSelect and in there create a STV tableview you want to show and push that view 


  • Morten Jacobsen likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#3 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 02 January 2016 - 09:27 AM

Or tell STV about your Accounts > Transactions > Transaction data structure and it can automagically produce the list > list > form for you.


  • Morten Jacobsen likes this
Cheers,

Dave

www.dgapps.ie

#4 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 02 January 2016 - 12:29 PM

Or tell STV about your Accounts > Transactions > Transaction data structure and it can automagically produce the list > list > form for you.


This sounds like music to my ears! But how do I tell STV this?

#5 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 03 January 2016 - 04:30 AM

Hi Morten,

 

 

What's your current data model?

 

Are you using Core Data?

 

How are you currently telling STV about your data model?


  • Morten Jacobsen likes this
Cheers,

Dave

www.dgapps.ie

#6 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 03 January 2016 - 05:24 AM

Yes, I'm using Core data.

 

Here is a picture of my data model.

 

I normally put an SCEntity in the view top bar, and set its name Account

I then set the SCArrayOfObject Data definition also to Account. And then the detail is an Account Form. I've tried a lot of options but never managed to make Account list open a Transaction list.

 

If possible I would also liked that the transaction list was filtered to the account tapped.

 

I did make a prototype using swipes and achieved what I wanted. But it stopped when I didn't manage to set the Predicate string correctly in code. I didn't like it either. It was too much a hack.


Edited by Morten Jacobsen, 03 January 2016 - 05:35 AM.


#7 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 03 January 2016 - 05:37 AM

Hi Morten,

 

 

What's your current data model?

 

Are you using Core Data?

 

How are you currently telling STV about your data model?

I just did a new post answering your questions. I'm not very comfortable in the forum's mechanic yet ...


Edited by Morten Jacobsen, 03 January 2016 - 05:37 AM.


#8 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 03 January 2016 - 06:07 AM

Ahh, are you using STV via Storyboards? I was stripping back a code example to show you. I'll see if I can do it with Storyboards!


  • Morten Jacobsen likes this
Cheers,

Dave

www.dgapps.ie

#9 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 03 January 2016 - 06:20 AM

Not only a storyboard guy. Also a Swift guy. And a SQL one too. My brain is curiously blind to Objective-C ;)

 

But earlier dBase and Paradox for DOS and Windows, Deplhi and Borland Database Engine was my real domains.

 

I'm longing to be able to work like before on iOS. STV 5x and Swift 2.0 is the best I've found.


  • wizgod likes this

#10 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 03 January 2016 - 02:52 PM

Greetings Programs!

 

I do something similar in my app; jumping from a list of children to the child's points activity.

 

I hope this is what you're looking for.

 

Wg

Attached Files


  • Tarek and Morten Jacobsen like this

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#11 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 03 January 2016 - 04:20 PM

It seems very relevant, and the data model is as similar as possible.

 

Still a lot to digest. I'll have my work set for tomorrow!

 

Thanks a lot!



#12 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 03 January 2016 - 04:26 PM

I got it working. Had just to copy in Sensible and CoreData frameworks first. The zip provided only pointers.

 

It is exactly what I hoped! And some more. For you also calculate the balances. You're delivered more than hoped for!

 

I'm very grateful that you've taking the time and given me the chance to get a crucial feature running!

 

Debug-day tomorrow :)



#13 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 03 January 2016 - 07:10 PM

 Had just to copy in Sensible and CoreData frameworks first. The zip provided only pointers.

 

thats because your not licensed to publicly distribute the framework files or the source code.. If you ever need to upload a demo or something on here to share or need help on, make sure you remove the STV parts (we have them anyways) plus the upload will be 30mb smaller :)


  • Morten Jacobsen likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#14 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 03 January 2016 - 09:25 PM

@Morten: My pleasure!

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


Hahahahahaha!

Wg
  • Dave Guerin, Morten Jacobsen and ozie like this

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#15 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 04 January 2016 - 04:17 AM

Nice one wizgod!

 

I'll have to study it as well.

 

And all that Swift, eek! I have to translate Swift in my head to Objective C to work out what it's doing...


Cheers,

Dave

www.dgapps.ie

#16 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 06 January 2016 - 04:38 AM

A lot to study and lot to learn for me @wizgod!

 

1. The actions - how nice they are lurking and waiting for their time to run!

2. Balance - I'm astonished that activity is the subset of activities related to an account. That's really wonderful. I.e. you don't have to scan the whole activity table :)

3. The same for the viewController. You just declare the data definition and there you are respecting the relational structure. What a joy!

 

I've tried to do it in the detail view STV sets up, putting in a SCArrayOfObjects and setting it to Transaction(Master). But it doesn't respect the relations. Just present all details in table. And a DetailSCTableViewController don't see the SCArray...

 

Is it mandatory to work from Accounts?

 

Do you think there any way to get this work through the DetailSCTableViewController and with less code?

 

Thanks a lot for valuable help. 2016 is already much better than 2015!


Edited by Morten Jacobsen, 06 January 2016 - 04:39 AM.


#17 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 06 January 2016 - 10:52 PM

I've tried to do it in the detail view STV sets up, putting in a SCArrayOfObjects and setting it to Transaction(Master). But it doesn't respect the relations. Just present all details in table. And a DetailSCTableViewController don't see the SCArray...

 

I'm not sure what you're doing there. Are you generating the detail view and replacing the cells with an SCArrayOfObjects?

 

Is it mandatory to work from Accounts?

 

No. You could add another TableViewController with just the Activity entity but you would still need to filter it.

 

Do you think there any way to get this work through the DetailSCTableViewController and with less code?

 

Not that I know of.

 

 

Ok so after all that, have a look at this modified version. I had STV generate the detail view in the storyboard and I removed all the cells and added the SCArrayOfObjectsSection and set the class to the new ActivityViewController class.

 

The issues are in the comments and you can (un)comment the various sections to see them. One other thing is that although the labels in the detail view have the correct constraints, the date label still shrinks.

 

And finally, you won't be able to add any accounts with this version since the detail view is no longer the detail view for the Account entity. You'll need to use the previous version to add them if you don't already have some set up.

 

Wg

Attached Files


  • Morten Jacobsen likes this

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#18 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 07 January 2016 - 05:21 AM

What a delight to get all this STV code @wizgod!

 

I just got a cold and will have to be indoor. It gives me a lot of time to deal with your code and comments.

 

My first impression is that i could be beneficial to ask @Tarek for this as new feature in his IB-components. In UI it could be as simple as a new checkbox in the Array of Objects section. We now have:

 

  • Allow adding
  • Allow editing
  • Allow moving
  • Allow Edit Detail View
  • Fetch in Batches

 

I suggest adding: "Use Form as Detail" to the list. When checking for this it works as of now. When unchecking it set up as a detail list.

 

My objective is to be able to easy manage the lists and form views from their respective view controller.

 

Doing it in code, like in the former one you provided, may be quite complicated given a larger number of different views.

 

What do you think? Is it worth a proposal?

 

Morten



#19 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 07 January 2016 - 07:53 AM

Even integrating even a simple thing as another checkbox into the STV plugin is a pretty complicated process.

 

That being said, it would be nice to have a check box that would "Push to Detail View" on the SCArrayOfObjectsSection but then on the implementation side there's the other SCArrayOfs to consider too (and some questions that SensibleCocoa developers would need to consider):

Would the checkbox be appropriate in those as well? How could it be accomplished? Would coding the implementation it be too complicated/time consuming for the feature? Would it be worth the time? When having multiple SCArrayOfs that have been flagged as "Push to Detail View", which is actually used? The first one in the list? Would it be possible to put a check in place that disabled the flag if it was already set elsewhere? Would it be complicated/worth the time?

 

When you manually create an SCTableViewModel and push out the view controller, it loses all links to the data definitions in the storyboard and that's why they need to be added again in code. It would be nice if there was a way to keep the link going.

 

Wg


Edited by wizgod, 07 January 2016 - 07:57 AM.

  • Morten Jacobsen likes this

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#20 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 07 January 2016 - 08:19 AM

Have a look at my app:

iParent Points Tracker: https://itunes.apple...=975898181&mt=8

 

Main view controller:

  • If you're in edit mode or tap the profile image, you will go to the detail view of the Child entity.
  • Otherwise, tapping the cell will take you to the detail view of the Objectives Array of Objects in the Child entity
  • Now, if you're in edit mode or tap the objective image, you will go to the detail view of the Objective entity.
  • Otherwise, tapping the cell will take you to the detail view of the Points Array of Objects in the Objective entity.

Since I manually created the model and pushed out the view controller, I lost the link to the definitions in the storyboard and I had to code them all.

 

Wg


  • Morten Jacobsen likes this

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)






Also tagged with one or more of these keywords: models, sections, view-controllers

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users