set default value for detail in master/detail relationship form widget dialog button - google-app-maker

I have a master/detail relation similar to the relations sample provided.
In my example department has a one to many relationship with employee
I have a form widget(department) which has a button to insert an employee.
when I click on that button the correct dialog form is displayed but I am allowed to enter any department which I do not want.
I am looking to have the relation defaulted to the "parent" widget where it was clicked and ideally not be editable.

It's hard to give an exact answer without seeing your app, but you should probably replace the dropdown in the form with a label, that will make it not editable. You can bind the value of the label to the relation just like the value of the dropdown was bound.
A slightly easier option would be disabling the dropdown (look for the Enabled probably in the property inspector). But that could be confusing for your users since they might think it should be editable.
(Alternatively, you could just remove the field altogether if it's not important to show the relation.)
I think this only answers the "not editable" part of your question, if you want it to be pre-filled you either need to do some scripting, or use relation data sources.
I suggest using relation data sources, so right now you probably have something like:
app.datasources.Emp.create(), which creates a new employee.
Instead, you can use widget.datasource.relations.Emp.create(), which will create a new employee which has a relation to the current item in widget.datasource. If this button is placed in your department form widget, then that means it will create an employee related to whatever department is shown in the form.
Note that none of this stops users from changing the department of an employee, it just changes the UI. In lots of cases that is enough, but you may also want to add some server-side security controls if it's important to limit which users can create employees, change departments, etc: See https://developers.google.com/appmaker/security/secure-app-data

Related

Changing the function of dynamic links in info parts

I am trying to let an info part's dynamic link work so that it only opens the queried values in a list on the new form.
Basically now, if i click Installation No. on the form part below.
Then this form opens up with all the Installations, not only the related Installations.
What i want to happen is when the Installation No is clicked then the list should look like when the "more" button is clicked or like the image below.
It seems like this is the standard function but i want to know if there is a way to change it.
Does anyone know a solution to this or know if there is any?
Dynamic links should work on info part forms provided prerequisites are met:
A data relationship exists between two tables, usually as one-to-many (one parent row relates to many child rows).
Each table has a field of the same extended data type.
In the parent table, the extended data type field values uniquely identify each row.
The extended data type has a relation defined on it for the field in the parent table.
Each table is a data source for one of the two forms.
The parent form contains a button that launches the child form.

How to: Allow for a ListBox to have no selection

I am wanting to allow for a user to deselect all values in a ListBox. Normally, when the user deselects all but one item, that one item cannot be deselected. I want to make it so it can be.
Thanks
Essentially I'm aware of two ways of doing this:
Add an empty item to the list. You can even name this item "None" or something similar. Using a text has the additional advantage that it informs the user.
Use JavaScript to unselect the item that is clicked if it is the last item.
Note, either way, you change the default behavior of the listbox, which is what users are accustomed to. Changing the default behavior is generally not a good idea, which is why I would go for option (1) being the clearest towards your users.

Qt Database content view / manipulation as list view

I have a database, which tables should viewed in a widget. Seems simple, but I can't decide what to du or use.
Each row of the table should be viewed as one list view item, for instance, imagine table with this fields: id, title, content, date, number.
I need to view it as a list view (not hard-coded, it may also be another thing, if it is possible or better), and the label of the list view item should be the title field. But when the user clicks or double clicks on that item it should open all the contents of the current row in a separate widget. The all of these can be implemented easily by me, but I can't understand what to use: QListView with its model, or QListWidget? Or maybe QSqlTableModel? The last one is unfamiliar to me, I can read about from documentation, but if you have heard or met some kind things/applications, please provide a better solution for described problem.
Hope I could explain my problem correctly,
Thanks in advance.
Have you read about model/view programming in Qt? Basically you should use some model (QSqlTableModel, QSqlQueryModel, QSqlRelationalTableModel or create your own) an then attach it to QListView or QListWidget.

Drupal: Views: how to group fields

I've created a views of node and I've selected the "fields" option in order to select which fields to display and in which order.
Is there a way to group such fields ? It would be very useful to have parent divs in my html code.
thanks
There's a simpler way to do it: http://www.arsnova.cc/web-development-articles/2012-07-27/grouping-fields-together-drupal-views
Let's say you want to group fields 1-3 together within a div.
First, exclude fields 1 and 2 from display. (By "exclude", I do not mean to delete them from the views display; rather, click on the "exclude from display" button within each field's options.) The fields you exclude from display must come before the other field for this to work. If they don't, rearrange them so they do.
Go to field 3, and rewrite the results, inserting the token for each of fields 1-3.
That's all you need to do. Fields 1, 2, and 3 will now appear within field 3's div. If you want, you can also add additional markup within the "rewrite results" area.
Recently found the best way for my needs and apparently for the needs of many people:
Use views_fieldsets module https://drupal.org/project/views_fieldsets, it allows yo to create a grouping div to put fields inside.
Grouping is built into Drupal 8 Views. So no need for any extra modules. Here's how:
Edit your view (be sure it has fields)
Click Format's Settings
A box will pop up with all your selected fields
Look right underneath all the field names, there should be "Grouping field Nr.1"
Select the field you'd like to group by
Click Apply
If you want to subgroup with a second field, just go back to 2 then you'll see "Grouping field Nr.2"
That's it.
Yes, click on the gear next to the Style option (under Basic Settings) and set the Grouping field. Keep in mind, the grouping field needs to be added to the view, but you can check the Exclude from display option to hide it, if needed.
I'm pretty sure that would give you a parent div. If not, you could add the parent div, by overriding the default templates (look to the Theme: Information section, under Basic Settings, for more information).

Webforms App Layout Opinions?

I have a very simple webforms app that will allow field techs to order parts from the warehouse.
Essentially it work like so:
User selects a category from a filter dropdown, which then binds items of that category to a gridview control
User finds an item in the gridview and inputs a desired quantity (in a text box in a template field in each row)
User repeats 1 & 2 as needed
User sees a summary of the complete requisition
User confirms items and submits the requisition for processing
My no-brainer UI design so far is the generic dropdown-above-a-gridview where there's a category drop-down list that filters a gridview, like in the eye-catching asp.net ado tutorials:
    http://static.asp.net/asp.net/images/dataaccess/15fig01vb.png
Each gridview row (in my app, not in the image above) lists an item's details and can accept a quantity input in the template textbox if the user wants to requisition that item.
Given that a user will want items from different categories during a single usage session, I'm trying to figure out a good, user-friendly way to allow users to input a quantity for an item, have a warm fuzzy feeling that their input has been accepted/stored, then change the category filter (thus binding the gridview to a different set of data) and select other items from the gridview as many times as necessary before summing up their order and submitting it.
I've thought about putting another grid below the first and adding items to it dynamically as the user selects each item. But that seems awkward. Ditto with an unordered list or similar simple structure under the grid.
I've also thought about just storing the user's picks in view state or session state and displaying a summary on another page, kind of like a shopping cart sort of functionality. Maybe do that and use some sort of ajaxy goodness on the main page to display something warm and fuzzy when a quantity is input?
WWYD? What Would You Do?
TIA.
I strongly agree with your first choice: users need to see somewhere what they have chosen or they will probably keep choosing it over again thinking it failed. Waiting to display it on a summary page shouldn't even be an option. I don't see much wrong with binding to another grid, although a repeater is also a decent option. Well, there are many options. Anyway, if there is room to do this off to one side or another - especially the left- I definitely would, rather than at the bottom. Also, bonus points for enabling users to change the quantities (or delete all) of an item they already selected, wherever you choose to display this.
I like the idea of a search, but be careful with auto-complete. Google style is good where it displays results below, but I've seen people develop some that are way too aggressive and love to write over what you're typing: this is awful. Good luck.
Probably because both your choices are fine - it comes down to personal preference. The shopping cart idea is well known. But sometimes it gets old if you have to keep going back and forth between the cart and the item selection.
What's wrong with the separate grid? -That way you keep the selection list separate from the ordered items list?
Why tie the user to selecting the correct category and then selecting the quantity and hitting a button?
Why not use some type of autocomplete search so they can type in the produce name they want? Then a user could type "widg", get a drop town of choices, hit tab to go to a quantity field, enter a number, and then hit enter.
Display a quickie preview with the aucocomplete too, like as single row of your data.
Then throw all these into another grid at the top of the page if its a critical part of the application, maybe at the bottom if you think the actual grid results are important.
The reason I don't like category drop downs is people who are familiar with their jobs or company usually know the names and even skus numebers for what they are trying to do. Having them select a category instead of typing just slows them down. Also I hate running into the "which category is this?" moment. For example, is a chicken a pet, food, livestock, or food producer?

Resources