I have a table that has attributes not common to all rows that will be inserted, which mean my schematic will allow some columns to be empty and this will depend on the type selected.
The tables
Item table
ItemId
Name
Location
Typeid
Type table
Typeid
Desc
Upon a certain type selected (from a dropdown) in the form, some attributes in the item would be shown to the user and they would be have to be entered. How do I approach this.
You'll likely have a controller action (probably a controller) per table so you get separate urls for SEO. You'll also want a view per table as well as these values aren't really shared. You could create an ivory castle that would render a table given a generic List or DataTable, but if you're leaning that route, just use a control for it.
You can also do it with Javascript and AJAX. You can have a div which is hidden called 'item-form'. And on selecting one of the dropdown options, a javascript function can fill the item-form with the html for the selected item type (with the necessary attributes) and make the div visible.
Something like -
$("#dropdown").change(function(){
if($(this).val()==1)
$("#item-form").html(); //form with the attributes for type 1
else if ($(this).val()==2)
$("#item-form").hmtl(); //form with the attributes for type 2
});
You could fill the div's using calls to controller actions that are specific to the type selected which would return partial views.
Related
In App Maker, what is the simplest way to achieve the same result with a dropdown box that you can with a suggest box, which can return the whole record when you make a selection giving you the ability to assign associated record values to other fields on the page?
Consider a data model with three fields, (Code, Description, and Severity). Add a dropdown box to select the Code. Have the selection, (probably using onValueChange or onValueEdit), write the selected Code's Description to a label field beside the dropdown box. The Code's Severity will also be used to affect the style in some way like background color or something, but for this answer, merely assigning the value to a scripting variable will be good enough. It's the record value access and assignment mechanism I am after.
Clarification: This data model will not be the page's datasource. It is a secondary reference table used for assigning a code to a ticket. You can also assume that a record value will be written to a field in the page's datasource as well.
I would appreciate the simplest low code solution as we will have non-programmers attempting this. Thanks.
As long as you leave your value binding on the dropdown blank the following should work:
Set the options binding to:
#datasources.YourDatasource.items
You may want to consider changing the 'Names' binding to be the projection of a particular field in this datasource otherwise the values showing in your dropdown will only be the 'keys' from this datasource.
Then in your onValueEdit event you will gain access to individual fields like this:
var item = widget.datasource.item;
item.YourFieldToEdit1 = newValue.YourOtherDatasourceField1;
item.YourFieldToEdit2 = newValue.YourOtherDatasourceField2;
That would probably be the simplest way.
I am trying to implement a Many-to-Many relation between a class and its students in a form.
The form can be used to create or edit a class. Also students can be added to that class. To reduce the effort needed to enter students, I would like to add a multi-select that shows the entries from the students-table. But since the number of students is expected to be large, I would like to filter this multi-select.
I checked this question on filtering lists and the sample app "Project List. I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains and set the tables datasource property to STUDENTS
But, as I understand it, a multi-select element's value property must be bound to #datasource.item.students and its datasource property must be CLASS in order for the auto-saving to work.
Hence I wonder whether it is possible to filter a multi-select element.
I don't see the problem, but I think I see a misunderstanding.
You said: "I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains"
You need to bind the OPTIONS (not value) to the datasource query, as it is the options that will draw its records from the #datasources.Students.query datasource.
You can then set the VALUE of the multi-select widget to #datasource.item.students (where you want selected values from the student query options to be saved).
You will also need to set the NAMES property (since the options are likely student records). Names will be the Student datasource projection of whatever string field you want to appear in the options list.
I need to create two content types (Call List and Call Announcements), in Call Announcements there are 5 fields, in Call List there are 12 fields but 5 of them are mutual with Call Announcements, I do not want to create 2 different content types (Call List, Call Announcements) because when the user create a node, he should be able to choose where the node is shown (in Call List, in Call Announcements, Both).
(Call List and Call Announcements should be in the same database table)
How can I do these?
http://i.stack.imgur.com/LAgXM.png
You can create a single content type containing all the fields.
After that add a field with checkboxes with the options like, "show on call list" and "show on call announcements), This extra field can be used to decide how the create/edit/view behaves.
When Creating/Updating content.
Now you may go ahead and install conditional fields, if you want to conditionally show some field based on the values of checkboxes selected.
When viewing content
Use views to display the list. Here you can decide what is shown in the list by filtering the list by the checkbox values. As a bonus extra views would help you decide what fields need to be shown to the user.
I have a form where user picks a Item# and gets info for the selected Item. This form got enhanced by adding another filter, using a combobox control, to select a 'warehouse'.
I could use a lookup for the warehouse(the list is huge) to chosse a 'warehouse' but what am trying to do to query warehouse on Item# value and populate into combobox.
Tried to attached a screen shot, unfotunately, the system doesn't let me do it. If I need to put more details, please let me know.
Is it doable?
I would suggest you to do this with a temporary table. Create one in AOT, and declare it as global variable in your form.
When Item (datasource field or design control, choose what's more accurate for you) is modified, just delete table content, and fill it at your needs.
In the control lookup method, call temporary table lookup method, i.e. "static void lookup(TMPTable _tmpTable)". Do a SysTableLookup, with a standard query over TMPtable, but it's important to use QueryBuildDataSource.setCursor(_tmpTable) (I don't remember now where was method setCursor() in Query or QueryRun, search for it a bit).
I have a table in the database that store 4 category and the structure of the table is ID (GUID), description. I load the category into a dropdown list (asp.net webform) to allow people to select a category and based on what they selected. I'll then display info associated with their selection and hide the others.
Currently, i do a "select case" based on the GUID that i hard coded in code behind to display the associated info. Is there a better way to do this without hard code in GUID on the code behind?
What is the Data that's associated with the Guid/Description...
The data you've hardcoded sound's like a candidate for being added to the database itself.
If it's one piece of information per Category/Guid, then consider extending your Database Table to store that info to.
If it's multiple piece of information per Category/Guid, then consider creating a new Table With a CategoryID on it, and a foreign key relationship between your Category Table and your ExtraInfo table
You could query the database for the GUIDs when the app starts and cache them in a static Dictionary.
you could store the GUID in your web-config and load it at run time. then, you can easily replace that GUID with another w/o having to recompile.
You should have a Categories table and a Posts table (or whatever it is that you will tag with your categories). In the Posts table you have a column for the CategoryID (assuming each post can only belong to one category), so that you only have the category name in one place (normalize your data).
When you render the dropdownlist, you select the GUID:s from the database. No hard coding, and if you add another category (or remove one) the dropdownlist will automatically reflect the available categories.
If you bind the dropdown list to the Category row or a Tuple that contains the category name and the value you can load the Guid in your codebehind using the SelectedValue property. You will then set the DataTextField and DataValueField on the Dropdownlist.