Kentico smart search default option - kentico

I have a smart search filter that is filtering news items by tags which all works fine.
The query for the filter dropdown is as follows:
SELECT 'DocumentTags', TagName, TagName FROM CMS_Tag WHERE ##WHERE## ORDER BY ##ORDERBY##
I need to know how to add a default of "All" (essesntially no filter) to this list, but cannot work out how to do it.
The only option I have currently is to tag all documents with "All" tag then this would show up, but hopefully there is another way?

I typically query a default of of empty string, empty string, display text and use a UNION to bind it with the set of results to actually filter by:
SELECT '','','-- Select a Value --'
UNION
SELECT 'DocumentTags', TagName, TagName
FROM CMS_Tag
WHERE ##WHERE##
ORDER BY ##ORDERBY##

Related

How to set up prefixes on saved search for multiple choices in netsuite?

I have a multiple select field that allows multiple selections of colors. I created a formula that would append a prefix of "color-" to each selected list, but it only appends it to the the beginning of the field. I'm not sure how I can split the field results up for the formula to where I can get it showing up for all results.
CASE WHEN {custitemtag_color1} is NULL
THEN ''
ELSE 'color-'||{custitemtag_color1}
END
Results with multiple selections show: color-Black,Lime Green,White
Expected Results need to show: color-Black,color-Lime Green,color-White
What's happening is that NetSuite returns "Black,Lime Green,White" as a single result for the multi-selection, then you're prepending "color-" to that text returned. To work around it within your saved search, you could simply replace any instances of the comma (",") with ",color-":
CASE WHEN {custitemtag_color1} is NULL THEN '' ELSE 'color-'|| REPLACE({custitemtag_color1}, ',', ',color-') END

Using custom table to feed drop-down list datasource

Let's assume that I have Custom Table named Possible URL target parameters with code name xyz.PossibleTargets with 2 columns:
Explanation and Value.
How to feed drop-down field on page type with data to have Value (from table) as Value and Explanation as name in drop-down?
What I already tried and it is not working:
Generate value;name pairs divided by newline and place it as List of options:
z = ""; foreach (x in CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items) {z += x.GetValue("Value"); z +=";"; z += x.GetValue("Explanation"); z += "\n" }; return z;
Validator do no allow me to do such trick.
Set option Macro expression and provide enumerable object:
CMSContext.Current.GlobalObjects.CustomTables["xyz.PossibleTargets"].Items
In Item transformation: {%Explanation%} and in Value column {%TargetValue%}.
This do not work also.
Dropdown configuration
How to do this correctly? Documentation and hints on the fields are not helpful.
Kentico v11.0.26
I think that you should do it without marking field as a macro. Just type there the macro. Take a look on screen
No need to use a macro, use straight SQL, using a macro only complicates what appears to be a simple dropdown list.
SELECT '', '-- select one --' AS Explanation
UNION
SELECT TargetValue, Explanation
FROM xyz_PossibleTargets -- make sure to use the correct table name
ORDER BY ExplanationText
This should populate exactly what you're looking for without the complication of a macro.

locating visible elements

Is there any way to locate just visible elements with Watir?
I want to locate only visible forms (by the index param) so that Watir would return first or second visible text field.
How is it possible to filter invisible fields / elements?
Is it possible to do that with xpath?
This will return the first visible text field:
browser.text_fields.select {|text_field| text_field.visible?}[0]
You can set text in text field like this:
browser.text_fields.select {|text_field| text_field.visible?}[0].set "text"
This will return the second visible text field:
browser.text_fields.select {|text_field| text_field.visible?}[1]
Please note that element can be visible, but disabled.

JqGrid - losing ability to sort and perform multipleSearch when column header text is changed programmatically on gridComplete

This is my jqgrid - $("#list1")
When it loads, i.e. on the gridComplete event, I need to rename the column header texts.
Original column header texts are in this format - Colomn1, Column2 ...
On gridComplete, I change these header texts like this:
$("#list1_Column" + someNumber).text(someText);
However on doing this, I lose the ability to sort columns. Column headers are no longer clickable and hence I cannot sort the grid after this custom programmatic editing.
Similar thing happens when I try changing the texts in the search dropdown list (search modal - using multipleSearch: true)
When, on gridComplete, I change text values in the select list as per the grid column headers, like this -
var select = $('#grid_wrapper #fbox_list1 .ui-widget-content .sf .fields select');
$('#grid_wrapper #fbox_list1 .ui-widget-content .sf .fields select option').remove();
$.each(data, function (i, item) {
select.append('<option value="Column' + item.id + '">' + item.ColumnName + '</option>')
});
...I lose the ability to perform multiple search, i.e. the + and - buttons in the search modal disappear.
How do I get around these two issues? Retaining ability to sort and perform multiple search after having changed column header and search list text values on load.
Please guide.
The column header <th> element has two child elements: one <span> with the text of the column header and another with the sort icons which are hidden the most time. So if you want to change the text manually you should use another selector
$("#list1_Column" + someNumber+ " > span").text(someText);
If you do so you will change the text on the page, but not change the text in the colNames or in the colModel (if you use label property instead of colNames). The text will be used for example to create Multisearch dialog. You can make changes in the colModel with respect of setColProp method or use getGridParam to get reference to any internal parameter of jqGrid (which are objects like inclusive colNames and colModel) and then make any changes which you need.
The best way in my opinion to solve the described problems is to use setLabel method to change the text in the column header:
$("#list1").jqGrid('setLabel','ColumnName','My new Name');
this will solve both problems.

Problem searching MySQL table using MATCH AGAINST

I have a MySQL table containing event data.
On this table, I have a FULLTEXT index, incorporating event_title,event_summary,event_details of types varchar,text,text respectively.
Examples of titles include: "Connections Count", "First Aid", "Health & Safety".
I can search the table as follows:
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('connections');
Which returns the events named "Connections Count" no problem.
However, no matter what I try, I get an empty result set when running the following queries:
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('first aid');
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('first');
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('aid');
I tried renaming an event to "Rich Aid" and could search for that just fine. Also, "First Rich" works great too.
Any ideas of why this is happening or how to fix it would be great!
Thanks for your time.
Rich
"first" is a "stopword" and by default words below 4 caracters are not matched unless you specify ft_min_word_len value.

Resources