Tablesorter: set a widget option to true for one column and false for another. - tablesorter

I'm trying to figure out how to set filter_startsWith: true for one column, and false for another column. In the case of one of my tables, I have an int column and a varchar column. The int column needs to be sorted with filter_startsWith: true. The varchar column needs filter_startsWith: false. Any ideas?

Currently, the filter_startsWith option applies to all columns. It would not be too difficult to alter the plugin code to make it work per column; I will add this to my "to do" list.
If you want to set a default filter which always applies to a column, and prevents other filter types from working properly, then you can set the filter_defaultFilter option to use regex to target a specific column (demo):
$(function () {
$('table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_defaultFilter : {
2: '/^{query}/'
}
}
});
});

Related

Default value for selection type range in List Report(Fiori Elements)

I have created a List report application based on Fiori elements.
In my CDS, i have defined below property for filter :
#UI.selectionField: [{position: 80 }]
#Consumption.filter.selectionType: #RANGE
header.diffrence as DayNo,
Requirement is to display default value of filter (DayNo) less than equal to '5',
#Consumption.filter.defaultValue
gives only 'equal to' values.
Is it possible to set default selection operator to 'less than equal'?
regards,
Umar Abdullah

SQLite on iOS...alter table IF? [duplicate]

This question already has answers here:
ALTER TABLE ADD COLUMN IF NOT EXISTS in SQLite
(15 answers)
Closed 7 years ago.
I have inherited an existing iOS app codebase and have been told to alter a sqlite table but not use versioning (as in not just store a constant somewhere in the app that dictates how/whether to update the table). Is there a way to check whether a column exists and add that column if it doesn't exist without versioning?
Use SQLite's pragma table_info() to get a result set that includes one row per table. For example:
create table foo (bar text, baz text)
and
pragma table_info('foo')
That returns a two row result set:
[cid: 0, pk: 0, notnull: 0, name: bar, type: text, dflt_value: <null>]
[cid: 1, pk: 0, notnull: 0, name: baz, type: text, dflt_value: <null>]
So, perform pragma table_info('table') and then iterate through the rows returned and see if a row with a name value equal to the column you're looking for exists.

Table converter integer to image

I am fairly new to Vaadin and am creating a small application. Here I display a table with some columns. In one of the columns I have an integer which, depending on its value, I wish to show an image in that cell.
I have been looking onto table converters but have not find what I am looking for. Could someone help me on the road to get this to work?
Thanks!
You can accomplish this using a column generator.
table.addGeneratedColumn("imageNr", new Table.ColumnGenerator() {
#Override
public Object generateCell(Table source, Object itemId, Object columnId) {
Integer i = (Integer) source.getItem(itemId).getItemProperty("imageNr").getValue();
Resource res = getImageResource(i); // get the resource depending the integer value
return new Image(null, res);
}
});
The column id "imageNr" on the first line doesn't have to be the same as the item property id, but if it is it replaces the integer column in the table and also makes this column sortable according to the underlying integer value.

jqgrid search: How to specify search column?

I am using jqgrid on EF4 MVC3 (C#). I based search on this #Oleg 's solution, which works fine and fits for my needs.
I have the following columns defined in my grid:
...
{ name: 'Stato', index: 'StatoTicketID', width: 20, align: 'left', sorttype: 'int', searchoptions: { sopt: ['eq']} },
{ name: 'StatoTicketID', index: 'StatoTicketID', width: 20, align: 'left', sorttype: 'int', hidden: true, searchoptions: { sopt: ['eq']} },
...
As you can see, the column Stato is ordered by the index StatoTicketID (hidden integer field) and ordering works fine.
PROBLEM
When I try to search a value of Stato, the filter is passed on index StatoTicketID as string, while I'd like to search by Stato values. So I get an exception inside the controller which specifies that I cannot convert String type to Int32.
Does exist a way to specify on which column apply search, when index is on a different column, like in my case?
EDIT & WORKAROUND:
For now I solved my problem with the following workaround.
(inside foreach (Rule rule in rules) of FilterObjectSet by Oleg)
....
if (rule.field == "StatoTicketID")
{
rule.field = "StatoTicket.Stato";
propertyInfo = typeof(T).GetProperty("stringfield"); // where stringfield is a text type column of my model
}
I realize very well that is not an elegant solution, I expect a kind response by you, to know how to implement the required behaviour directly from jqGrid, please.
Thanks in advance
It seems to me that you chosen too complex way. I would just send to the client (to the jqGrid) only the Stato and have to StatoTicketID at all. From the design point of your the StatoTicketID is the part of the server implementation and the client should not depend from this.
If you have Unique Constrain (or unique index) on Stato column of the StatoTickets table you would very quickly find the StatoTicketID whenever you as need. So the jqGrid can contain and "know" only about Stato and have no information about the StatoTicketID as the implementation detail.
One more way to solve the problem is the usage of formatter: 'select' in the column Stato. It's important to understand that in the case the mapping between Stato text and the StatoTicketID should be loaded before the grid is created. In the case the Stato column should have the properties like
formatter: 'select', edittype: 'select', editoptions: {value: '12:Stato1;24:Stato2'},
stype: 'select', searchoptions: {value: ':All;12:Stato1;24:Stato2'}
One can't use dataUrl in the case instead of value in the editoptions.
As the result you will be able to fill column Stato with the StatoTicketID data, but the corresponding texts will displayed by jqGrid.
I recommend you better to implement the first way with pure Stato text. All the problems you would be able to solve only on the server part.

SQL Query: Using IF statement in defining new field

I have a table with many fields and additionally several boolean fields (ex: BField1, BField2, BField3 etc.).
I need to make a Select Query, which will select all fields except for boolean ones, and a new virtual field (ex: FirstTrueBool) whose value will equal to the name of the first TRUE Boolean Field.
For ex: Say I have BField1 = False, BField2 = True, BField3 = true, BField4=false, in that case SQL Query should set [FirstTrueBool] to "BField2". Is that possible?
Thank you in advance.
P.S. I use Microsoft Access (MDB) Database and Jet Engine.
If you want to keep the current architecture (mixed 'x' non-null status and 'y' non-status fields) you have (AFAIS now) only the option to use IIF:
Select MyNonStatusField1, /* other non-status fields here */
IIF([BField1], "BField1",
IIF([BField2], "BField2",
...
IIF([BFieldLast], "BFieldLast", "#No Flag#")
))))) -- put as many parenthesis as it needs to close the imbricated IIFs
From
MyTable
Of course you can add any Where clause you like.
EDIT:
Alternatively you can use the following trick:
Set the fields to null when the flag is false and put the order number (iow, "1" for BField1, "2" for BField2 etc.) when the flag is true. Be sure that the status fields are strings (ie. Varchar(2) or, better, Char(2) in SQL terminology)
Then you can use the COALESCE function in order to return the first non-value from the status fields which will be the index number as string. Then you can add in front of this string any text you like (for example "BField"). Then you will end with something like:
Select "BField" || Coalesce(BField1, BField2, BField3, BField4) /*etc. (add as many fields you like) */
From MyTable
Much clearer IMHO.
HTH
You would be better using a single 'int' column as a bitset (provided you have up to 32 columns) to represent the columns.
e.g. see SQL Server: Updating Integer Status Columns (it's sql server, but the same technique applies equally well to MS Access)

Resources