Set text column filters to do a full matching check instead of 'Contains' - datagrid

We are using AG Grid React Enterprise with Adaptable.
When we filter on text columns we want to filter for exact matches only but the default seems to be Contains and its annoying for our users to have to remember to change it each time they run a filter and when they forget to do it they end up seeing false positives.
Is there some code we can run so that when the user enters filter text it will force the Grid to do a full match check?

You can set this at design time in SearchOptions where there is a defaultStringColumnFilter property.
The default value is 'Contains' which is why your users are seeing that, but you can change this to another Predicate. So if you want an exact match then set the value to 'Is'.
You can also set the default filters for Number and Date Columns from the current default values of 'Equals' and 'On' respectively. For example:
searchOptions: {
defaultStringColumnFilter: 'Is',
defaultNumericColumnFilter: 'GreaterThan',
defaultDateColumnFilter: 'After'
}
See more at Search Options documentation: https://docs.adaptabletools.com/docs/adaptable-options/search-options/

Related

Display label based on, field on one data-source (singular) being within another data-source fields many

I am still learning, and looking for help on how to display a label based on one data-sources field value, being within another data-sources field value list.
I have one calculated table, displaying rows of documents within a folder, and wish to use a field representing the document number in that data-source, so that if it's ANYWHERE within another tables field it displays my label.
I've been trying to use projection as I think this is how to achieve it.
I can get it working based on both the current #datasouce.item.fieldnames but need it to base the calculation on all possible numbers in that tables field (Image below should make it easier to understand).
I expect that it has something to do with projections, but can't find anything within the learning templates or anywhere else to resolve the issue.
I think the following should work for you. For the 'Reserved' label have the following binding for the text property:
(#datasources.project_quotes.items..quotenumber).indexOf(#widget.datasource.item.Qnumber) !== -1 ? 'Reserved' : ''
I would suggest alternatively just to include a field in your calculated datasource and making the determination in your server script.

How can I add a conditional field

I would like to have one field appear conditionally based on the value of another. How should I go about achieving this in dexterity?
E.g. One field is a boolean: Is the resource for sale?
If this is set as "yes" I'd like the next field to show up, being an integer- the price of the resource.
If I had to guess, I'd start hacking a javascript solution but I'm assuming there is a technique for doing it in an organised manner, but I can't find anything.
I should also mention that I am doing this to simplify the process of searching through this content later (using eea.facetednav) in which I don't know how to have a boolean search interface return results based on if the integer is > 0.

set empty text behavior for django-tables2

Some columns in my django table happened to be empty and as a result the text rendered there is 'None'.
I would like to see a blank space instead.
django tables2 has some documentation on the subject, but I don't understand it completely.
Where do I have to define this empty_text behavior parameter? Tried in the relevant class meta, but apparently it has no effect.
You can override the default value in your column definition.
If you are not explicitly declaring your column (for example you are letting tables2 figure it out from your model) then you will have to define it so that you can set options for it. It is ok to do that with data coming from models.. as long as the column name you define matches the model field name it will match them up.
class TableClass(tables.Table):
mycolumn = tables.Column(default=' ')
If you need to dynamically work out your default value on a row-by-row basis then define your column and pass empty_values=[], eg:
class TableClass(tables.Table):
mycolumn = tables.Column(empty_values=[])
This tells tables2 that it should not consider any values to be 'empty'.. you can then declare a custom rendering method for that column:
def render_mycolumn(value):
# This is a very simplified example, you will have to work out your
# own test for blankness, depending on your data. And, if you are
# returning html, you need to wrap it in mark_safe()
if not value:
return 'Nobody Home'
return value
Keep in mind that render_ methods are not called if tables2 thinks the value is blank hence you must also set empty_values=[].
Here is the tables2 documentation which describes how custom render methods work: http://django-tables2.readthedocs.org/en/latest/pages/custom-rendering.html?highlight=empty#table-render-foo-method

getting textfield output partly unvisible

In a Drupal content type a need to get the output of a field partly unvisible. These are bank account details, the IBAN.
Normally the field shows 1234567. I need to get xxxx567. I need to show only the last 3 numbers/letters.
Also I need this output in field edit form.
On the display end you could change the output using a simple PHP function in the theme template by grabbing a substring of the field's last three digits and concatenating it with "xxxx" before printing.
You might also consider doing this at the formatter level by using the 'custom formatter' module perhaps?
https://drupal.org/project/custom_formatters
To do this on the edit screen is trickier. I suppose you could do a hook form alter to use PHP to change the field value, but I am afraid you will rewrite the field value when you save the node with the 'xxxx' instead of the real data.
I wonder if it would make sense to 1.) hide the actual field, 2.) create a dummy field that displays the text formatted as "xxxx567" to the user, and 3.) write some javascript that populates the hidden field with the visible field's value if it is changed. Presumably the form would still throw values if the hidden field did not meet formatting requirements.

dynamodb creating a string set

I have a lot of objects with unique IDs. Every object can have several labels associated to it, like this:
123: ['a', 'hello']
456: ['dsajdaskldjs']
789: (no labels associated yet)
I'm not planning to store all objects in DynamoDB, only these sets of labels. So it would make sense to add labels like that:
find a record with (id = needed_id)
if there is one, and it has a set named label_set, add a label to this set
if there is no record with such id, or the existing record doesn't have an attribute named label_set, create a record and an attribute, and initialize the attribute with a set consisting of the label
if I used sets of numbers, I could use just ADD operation of UPDATE command. This command does exactly what I described. However, this does not work with sets of strings:
If no item matches the specified primary key:
ADD— Creates an item with supplied primary key and number (or set of numbers) for the attribute value. Not valid for a string type.
so I have to use a PUT operation with Expected set to {"label_set":{"Exists":false}}, followed (in case it fails) by an ADD operation. These are two operations, and it kinda sucks (since you pay per operation, the costs of this will be 2 times more than they could be).
This limitations seems really weird to me. Why are something what works with numbers sets would not work with string sets? Maybe I'm doing something wrong.
Using many records like (123, 'a'), (123, 'hello') instead of one record per object with a set is not a solutions: I want to get all the values from the set at once, without any scans.
I use string sets from the Java SDK the way you describe all the time and it works for me. Perhaps it has changed? I basically follow the pattern in this doc:
http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_UpdateItem.html
ADD— Only use the add action for numbers or if the target attribute is
a set (including string sets). ADD does not work if the target
attribute is a single string value or a scalar binary value. The
specified value is added to a numeric value (incrementing or
decrementing the existing numeric value) or added as an additional
value in a string set. If a set of values is specified, the values are
added to the existing set. For example if the original set is [1,2]
and supplied value is [3], then after the add operation the set is
[1,2,3], not [4,5]. An error occurs if an Add action is specified for
a set attribute and the attribute type specified does not match the
existing set type.
If you use ADD for an attribute that does not exist, the attribute and
its values are added to the item.
When your set is empty, it means the attribute isn't present. You can still ADD to it. In fact, a pattern that I've found useful is to simply ADD without even checking for the item. If it doesn't exist, it will create a new item using the specified key and create the attribute set with the value(s) I am adding. If the item exists but the attribute doesn't, it creates the attribute set and adds the value(s). If they both exist, it just adds the value(s).
The only piece that caught me up at first was that the value I had to add was a SS (String set) even if it was only one string value. From DynamoDB's perspective, you are always merging sets, even if the existing set is an empty set (missing) or the new set only contains one value.
IMO, from the way you've described your intent, you would be better off not specifying an existing condition at all. You are having to do two steps because you are enforcing two different situations but you are trying to perform the same action in both. So might as well just blindly add the label and let DynamoDB handle the rest.
Maybe you could: (pseudo code)
try:
add_with_update_item(hash_key=42, "label")
except:
element = new Element(hash_key=42, labels=["label"])
element.save()
With this graceful recovery approach, you need 1 call in the general case, 2 otherwise.
You are unable to use sets to do what you want because Dynamo Db doesn't support empty sets. I would suggest just using a string with a custom schema and building the set from that yourself.
To avoid two operations, you can add a "ConditionExpression" to your item.
For example, add this field/value to your item:
"ConditionExpression": "attribute_not_exists(RecordID) and attribute_not_exists(label_set)"
Source documentation.
Edit: I found a really good guide about how to use the conditional statements

Resources