I have a custom paragraph type - which has 2 fields:
Display Mode,
View to be rendered
I want to let users choose Display Mode in this paragraph, then I will render view based on this Display Mode value.
The problem is, it seems there is no way for me to get this Display Mode value inside view template(views-view-unformatted.html) or hook (HOOK_preprocess_views_view).
Only what I can access is view object, which definitely does not have any parent entity info.
Any idea?
Related
I have a QAbstractListModel that has a bunch of custom objects stored in it, and you can access the different fields of the custom objects in the model by specifying a role (if this is an improper use of Qt roles let me know because I must be confused). I want to display this data in a user friendly QTableView. I can get things displaying using a proxy model, but the issue is I don't want to display the raw values, I want to display specific data derived from the raw data. So for instance, I don't want a column for both ItemA.foo and ItemA.bar, I want to display just ItemA.foo - ItemA.bar in a single column. And to add to that, I want the automatic update functionality you get with models where if either ItemA.foo or ItemA.bar change, I want the difference column to automatically update and recalculate.
I would think that the way to do this would be to use some kind of table proxy model that listens to the source model, and then populates its own fields with the values derived from the source model and listens for dataChanged() signals from the source model. Then you plug this proxy model in to a QTableView. But to me this sounds like something that should be done in a view. Or is this something that should be done by the delegate? I could even go so far as to do these calculations in the base model itself and add roles specific to these values that should be displayed in the table, but that sounds like I am really overloading the responsibilities of the model.
TLDR: How do you manipulate data from a model in a QTableView? Should I do the data manipulation in the base model and then send that to the QTableView? Should I use a proxy model that manipulates the base data and sends it to the QTableView? Or am I completely misunderstanding something?
and you can access the different fields of the custom objects in the model by specifying a role
If you look at the documentation for Qt::ItemDataRole, you would see that Qt models should indeed provide different data for different roles but each role means some distinguished purpose of the data corresponding to the role. For example, the most commonly used role is probably Qt::DisplayRole as the data for this role defines the content displayed in the view e.g. it's the text in the table cell. If you are satisfied with all the other aspects of the view - font, background etc - you can just return empty QVariant for corresponding roles from your model, the view would figure out these details on its own. If you are using roles as a substitute for columns i.e. to return different pieces of conceptually the same data item, it is probably not the intended use of roles.
For the other part of your question - you can customize the appearance of data displayed in the view through the use of a delegate. For example, you could subclass QStyledItemDelegate, override its displayText method to display ItemA.foo - ItemA.bar instead of just ItemA.foo and then set this delegate into the column of your view corresponding to ItemA.foo via setItemDelegateForColumn. The tricky part here would be to detect changes in both ItemA.foo and ItemA.bar columns which would affect the text displayed in the delegate. A while back I implemented a dedicated class in one of my projects which listens to changes in some column of the original model and "reroutes" the change into another column through signal emitting. I did it to solve this very issue - to catch changes in what delegate should display although technically another model column is affected into which the delegate is not set.
I would like to change the color of the Display Only text on a form depending on its value. As I read it, I have created a Dynamic Action to set it, but it doesn't work. To test it, I created a second True Action in the same place that sets the value of another item. This works, so the Action fired, but the color did not change. I tried coloring by a static value (f.e. green), but nothing changed. I have an another simple test project where this method works.
The APEX version is 21.1.6
If you check the properties of the display only item in the inspector you'll see that the actual page item has an input tag with attribute "hidden" so it is not displayed. Following the hidden element there is another tag with an element id of item_name_DISPLAY. That is where you want to set the style.
Example:
Page item "P33_DISPLAY_ONLY" of type "Display Only"
Dynamic action on change of "P33_DISPLAY"
True action of type "Execute Javascript" with code
$('#P33_DISPLAY_ONLY_DISPLAY').css({ color: "red" });
Note the id: it is P33_DISPLAY_ONLY_DISPLAY not P33_DISPLAY_ONLY
Add a client-side condition to each true action per color you want to set.
Scenario:
Application is tab-based; one tab is a container view having a 'Picker (Data) View'.
Picker View: the Picker is initially loaded with data via #State -> #Binder.
A 'Front Page' (Greetings) View is initially displayed over the Picker View within a ZStack{}.
User Acknowledges the front page which disappears to reveal the Picker View (#2).
Note: Data is received by the Picker per debug check.
The hidden Picker View shows the initial data.
Problem:
The revealed Picker View becomes empty; after dismissing the Front Page/View.
The following is a debug listing via BreakPoint of data:
Observation:
I want to access the data source ASAP to populate the Picker View to avoid having the user wait for the data. Hence the data is initially access prior to revealing the Picker View.
However,
the Picker View apparently gets re-rendered just prior to being displayed.
Note: I see the populated picker page if I comment-out the front-page code.
👉 I've added a boolean filter to avoid calling the Picker with an empty data payload.
Question:
How do I make the data more permanent; that is, stay until it is dismissed?
Do I have to make a concrete copy of a #Binding variable?
Non-SwiftUI fix:
Use a Singleton for the persistent data vector; and hence not influenced by the life of the controlling View:
final class DataSource {
static let shared = DataSource()
var myVar:String = "Hello World"
var countryNames: [String]?
}
This is so simple that it's elegant.
Still, I would like to use combine here, but the data life is too volatile.
I plan to review this paradigm further into my project as I become more proficient in Combine.
If anyone has a SwiftUI/Combine method of accessing, holding/sharing data that doesn't require a Singleton object, please post.
Need a help in understand underline logic here. I have created a simple APEX application. First page shows the table details and via a "Create" button "Interactive Search" region, directs to a form page. Now form page consists of "Save" and "Insert" buttons in correct regions. So whole app works. When I press "Create" from 1st page to 2nd, "Save" button is invisible and when I click the edit icon on the table of 1st page, "Create" button is invisible in 2nd. App works accordingly, but could not figure out what setting enable this set-up even though I was able to make it work.
1st Page : Interactive Report Page. 2nd Page : DML Form. Built the app from blank pages.
Could any of you explain how it works?
When you click the Create button on the Interactive Report page, it takes you to the Form page in insert mode, i.e. it allows you to enter a new row into the table. Therefore, the Form page has the Create (and the Cancel) button.
On the other hand, when you click the Edit button on the Interactive Report, it takes you to the same Form page, but this time in edit mode which enables you to modify values (and save those changes with the Apply Changes / Save button), delete that row using the Delete button, or - as previously Cancel current operation.
If you look at Form page's buttons' properties, you'll see that they have Server-side Conditions set which are then used to render (or not) a certain button. For example, if the Form page number is 13 and the primary key column is set to the ID column, then these conditions look like this:
Create: P13_ID IS NULL (i.e. the primary key column value doesn't exist yet, which means that this is a brand new row)
Apply Chanages / Save: P13_ID IS NOT NULL (i.e. the primary key column value exists, which means that row you see was fetched from the database)
Delete: P13_ID IS NOT NULL (the same condition as for the Apply Chanages / Save button)
Cancel: it is always displayed.
I am working with 4 views using a Tab Bar. The first view has a tableview of rounds of golf. The second view allows the user to enter data for a new round. I have a button on the "Add Round" view that saves the inputted data to Core Data. When the user saves the round I want the view to segue back to the "home screen" where the rounds are displayed. I created a segue called "SavetoHomeSegue" in storyboard.
This is the code I use to switch between the views
[self performSegueWithIdentifier:#"SavetoHomeSegue" sender:self];
[self.tabBarController setSelectedIndex:0];
Here is my issue: When I switch back to the "Home Screen" the tableview now appears for the first tab AND the second tab. Also, it doesn't seem like the "Add Round" view was properly unloaded as I was previously having to manually clear the data inputs in the textfields. How do I transition from one tab to another and properly unload the views? I have posted my views below:
Home Screen View -
Add Round View -
You definitely shouldn't be segueing between tab bar vc's. Just save the data and refresh the other view on viewWillAppear. Call setSelectedViewController when necessary, but never segue between tab bar vc's.