I would like to limit the options of a drop down box based on a status column on a table in rails. For example this model would have a status flag of T or F. If the row was T I would like it to display as an option in the drop down box. Any suggestions appreciated.
That shouldn't be hard, just make a class method in the model that returns a hash, pass in whatever info you need (the T or F) and as long as it returns a hash form helper should be able to parse it. I fill select boxes all the time using Model contants, same principle.
Related
I have a model in which I created all the data types of Odoo, char, float, many2many…. etc, I show this model in a view where, depending on the type of data selected by the user, “only one” of these types of data will be shown to enter a value. I am showing the type of data selected by this domain in the view -> attrs = "{'invisible': [('fields_type', '! =', 'Char')]}"
In addition, when “only one” of the fields is saved in the database, the other values in the line are in <null>.
My questions are:
Will there be any “dynamic” way to show only the selected field, without having to load all fields in the view and hide them with attrs?
What would be an "optimal" way to store these values in a database? Do all fields in a single model or should I separate the different fields using some kind of inheritance?
Thank you !
Hello Manuel Alejandro Bouza Lavoy,
Yes, you can do it in a dynamic way with fields_view_get method. Where you can check your condition and based on that you can add on your view.
2nd thing you can use with one model to store the value in the database.no need the separate models.
Thanks
Guys!
I'm working on a project with Bizagi Suite - Version 11.1. I'm new to it and I will really appreciate your help, because I'm having a hard time creating a dynamic combobox control.
So my case is the following:
Data Model: 3 master tables: Program, Order and Order-Program (m-m relationship). In table Program users fill out year, positions and amounts for each position. In table Order, they fill out info about the order and they have to specify from which program they want to take the money out for the order. The Program itself has a lot of records with different positions and amount. And I want when the users fill out the order to select the year, the position and the amount they want to take out of the program. So I need to have a dynamic combobox for the field 'position' which loads when user select year.
In other words I need to load combobox with filtered records of master table.
Do you have any ideas how I can do that?
Thank you in advance!
Best regards,
A.Mincheva
You must define your combobox with the full content of the master table.
Then ,you can define a Filter expression to dynamically filter the combobox content.
In the filter expression, you need to retreive the value of selected Year with XPath and use this value to filter the records.
In the form designer, you go to "Actions & Validations" to define the following action :
When "Year" changes <=The display name of the input field
Then Refresh "Program" <=The display name of your dynamic combobox
tldr: Can not update records from query because of aggregate functions. What workarounds do you suggest?
I have a table containing decision criteria to which a user can assign a relative weight. I calculate the absolute weight in an SQL query using an aggregate function (as described here Divide the value of each row by the SUM of this column).
qryDecisionCriteria
name relative_weight absolute_weight (calculated)
price 2 50 %
quality 1 25 %
experience 1 25 %
I would like to present the query result in a form, where the user can update the relative weights, and then sees the absolute_weights.
However, the query results are not updatable, because the query involves an aggregate function.
What alternative methods or workarounds could I use, so that a user can edit relative_weights and view absolute_weights as a kind of visual feedback?
I read about temporary tables here http://www.fmsinc.com/MicrosoftAccess/query/non-updateable/index.html but I'm not sure, how to implement this.
Maybe I could also create an additional "edit form" based on a simple query, that is automatically invoked when the user selects a record in qryDecisionCriteria data?
Or maybe just display data from two queries (one updatable, one with the calculated field) next to each other in the form?
Which options would you recommend and why?
Make the Record Source for the form the updatable base query. In the text box which shows the calculated absolute weight set the control source to
=DSum("relative_weight","<base table name>")/Forms!<Form Name>!relative_weight
You'll need to be sure that you do two things with this
When you drag fields onto a form in Access it makes the name of the control the same as the control source column. this is really annoying and can cause a lot of headaches. Rename your control to something like txtColumnName. That way Forms!<Form Name>!relative_weight is guaranteed to reference the field and not the textbox.
in the AfterChange event for the relative_weight textbox you should add an event handler in which the following code is run
txtabsolute_weight.Requery
This will make sure the formula is recalculated whenever someone changes a weight. Otherwise they need to hit F5.
I have one textbox basically the user is going to enter in a 9 digit number or letters. From there I want to have a buttonclick event that validates this against 2 columns in a MSSQL Database. First to check if the number exists, next to check if it is active or inactive.
There are about 27000 rows of numbers so my main question is what is the best approach to handling something like this.
Should I create a view and validate in the click event.
Should I create a stored procedure in sql that takes an input parameter and call it in the click event.
I was also reading about storing the information in a dataset however with that many records i am assuming that is going to be a slow process.
If none of these approaches are right I would appreciate the correct way to go about doing this and maybe a few links that can get me started. I searched but most people are using a dataset and if that is not going to affect my performance I will more than happy to approach it that way just not too sure.
Thanks
Stored Procedures and Views should work the same as long as you have a where clause that filters down to exactly the data you want, rather than (in the case of the view) returning all rows from the view and then filtering in memory. It would need to look like this:
Select Number, Activer from ViewName where number = (your number)
or
EXEC spValidateNumber #Number = (your number)
As for when to do your validation, if this procedure takes more than, say, one second, you should probably have the user ask for validation by clicking a button, so that they anticipate the delay. If it runs on the textbox's lostfocus event, it should run without any noticable delay for the user.
Friends,
I am new to lucene full text search. i have developed page with full text seach. it works fine till. but now i want to add extra condition like where clause. how to do it.
The requirement given for me is, i have to list proposal which is created by logged in user. I have to add this condition in back end without user knowledge.
I heard about filter. Which filter is correct?how to apply that.Give me an sample. this evening i have demo. help me.
First, you need to ensure that the user id is being added to the document in the index in a field when you index, let's call it user_id.
In a pinch, you can add a field to the query string entered by the user behind the scenes before you send it to the query parser. So, take whatever query was entered and add " AND user_id:4" (where 4 is the value of the variable containing the current user id) onto the end of it.