I want to use a QComboBox with the "keys" and "values" from a tuple similar to the ones used in a django models. For example I have the following structure for a person's sex.
SEX_CHOICES = (('M', 'Male'), ('F', 'Female'))
The first item of the tuple contains the code of the sex that is stored in the database, and the second one the text that I want to display in the QComboBox as an item.
Is there a way in wich I could set the QComboBox value as M and it displays Male. An also when the user select the element Male I could get the selected value as M.
Thanks
Use
cb.addItem ( text, userData )
and pass the DB key as userData. If you need to change the current selection, use cb.itemData() to get the DB key of each item and compare it to the one you need.
Alternatively, record the indexes as you add items in a Python map and use this to directly look up the correct index.
To make things more easy to use, wrap the QComboBox with a Python class that offers setters and getters for the current DB key and which hides the mapping.
Related
I am trying to divide values and display it in a new custom field(usrQuantity)on Stock Items Screen.
I want to divide OpenQty (which is a column in POLine) and CARTONQTY(which is not a column name but just an attribute in column AttributeID in CSAnswers table).
enter image description here
I am confused how to perform this division since CARTONQTY is not a field, I noticed that there is a field named CARTONQTY_Attributes in InventoryItem table which has been generated by some Join queries but is not actually present in the Database(checked in SQL Management Studio).
enter image description here
I tried this formula in the DAC of usrQuantity
[PXDBInt]
[PXUIField(DisplayName="Quantity")]
[PXFormula(typeof(Div<POLine.orderQty,InventoryItem.CARTONQTY_Attributes>))]
But it is giving following errors
The type or namespace name 'POLine' could not be found (are you missing a using directive or an assembly reference?)
The type name 'CARTONQTY_Attributes' does not exist in the type 'PX.Objects.IN.InventoryItem'
Do you want to store the value in the db? Typically it's not recommended practice to persist calculated values unless, for example, there's a performance issue in performing the calculation on the fly. If you don't want to store it, you probably want a PXInt instead of PXDBInt. Also, unless you always expect a whole number as a result of your division (which is unlikely), you should probably use a PXDecimal type.
To then get your calculated value into your new field, I would probably set it in RowSelecting and RowUpdated event handlers by extending the appropriate PXGraph class; in order to calculate it as you retrieve a row and when you update the row values.
I have an sql view V which has a 0:1 correspondence to a table X. I would like to join this view onto another table, Y, which has a reference to X (type XId).
I have specified the view as I would any other table in persistent. V's id column is a reference to X, but declaring the view as a table in persistent naturally gives it the type VId
instead of XId. And so I can't join the view onto Y because the types don't match up.
I realize I can do this with rawSQL, but my query also has an IN clause, which doesn't seem to play well with a list of values (using rawSQL).
Another option is to select the XId column twice in the view, and specify the extra one as having type XId in the model definition.
Lastly I could fall back to inserting the view query inline or doing the query entirely with raw sql, skipping persistent's interpolation.
Is there a way to do this without resorting to the methods above?
I'd prefer to use esqueleto if possible.
I haven't found a proper solution to this yet.
For the time being I am selecting each primary key twice in the view eg
... SELECT id, id AS xId...
along with adding the corresponding table's key type to the second selected id in the view schema:
XView sql=xView
...
xId XId
I have a list with a lookup column that is getting "Created" dates from another list, but I only want the unique date values. Is there a way to get this data or to create a calculated column with unique values?
A lookup field actually links to a single item, the display value is more a "human readable" value for the link to the items ID value.
You may also get some mileage from a normal text or even date field and using jQuery and SPServices on the edit and new forms in order to provide changes to the form for the user. This avoids doing a code level customisation for the site that a Custom Field would require.
Not out of the box I dont think. My best bet is to create a Custom Field type that extends lookup with the functionality you are after.
I've been trying to filter the view by second sorted column but so far it doesn't work.
(my underlying view is sorted by first column categorized and sorted by ascending, and the second column is sorted by ascending order as well)
How can i get through this thing? and I don't want to create one more view for this filtering
To filter by multiple keys you need to use a Java Vector with the keys you want to filter by. Here's an example of applying a filter to a sessionScope variable that you then use for the keys property of the view:
var vArray = new java.util.Vector();
vArray.addElement("key1");
vArray.addElement("key2");
sessionScope.put('viewFilter', vArray);
For search function, We have two different ways are there. One is normal search just like OS level.And another is Full index search.
Please follow the below link, U will get better idea,
[Search Query][1]
[1]: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPagesViewControlAddFullTextSearch.htm
I am trying to full text search a column, but also be able to group by it. Does that mean it needs to be attribute? I want to still be able to search on the column though.
Use sql_field_string to make a column both a full-text field, and an attribute.
http://sphinxsearch.com/docs/current.html#conf-sql-field-string
Then you can query it, and sort/group by it.
Yes, you need attribute to use group by in Sphinx.
For example you could use crc32(text) of your text column. Like:
sql_query = select text, crc32(text) as text_crc from mytable
sql_attr_uint = text_crc
So, text will be used for full-text search and text_crc for group by.