I am using Xamarin Studio on Mac machine and working on Xamarin Forms project. My requirement is - I have Entry field, OnTextChanged event of entry field I want to display only those item in ListView which are starting with entered text. For this moment, I am using below code to implement it-
entry_excludeIngredients.TextChanged += (s, e) => {
listof_excludeIngredients.ItemsSource = container;
if (string.IsNullOrEmpty(entry_excludeIngredients.Text))
{
listof_excludeIngredients.ItemsSource = null;
listof_excludeIngredients.IsVisible=false;
}
else
{
listof_excludeIngredients.ItemsSource = container.Where(x => x.StartsWith(entry_excludeIngredients.Text));
if(listof_excludeIngredients.ItemsSource==null)
listof_excludeIngredients.IsVisible=false;
else
listof_excludeIngredients.IsVisible=true;
}
};
But I am facing one issue that is above code is case-sensitive. If you enter "r" ListView is showing only results starts with "r" but not with "R".
Change
listof_excludeIngredients.ItemsSource = container.Where(x => x.StartsWith(entry_excludeIngredients.Text));
to
listof_excludeIngredients.ItemsSource = container.Where(x => x.StartsWith(entry_excludeIngredients.Text,StringComparison.CurrentCultureIgnoreCase));
Related
In Wix, I have a text field in a repeater that is used for navigating to other dynamic pages. The link works, but there are two problems with that. First, I have to click two times, not double click, for functioning the link. Second, I want to make the text field act as a button link, I mean be able to right click on that and choose 'open in new tab'. How can I fix these problems in my code?
Here is the code
// Navigating to related dynaic page
import wixLocation from 'wix-location';
export function ndText_click(event) {
$w("#repeater1").onItemReady(($item, itemData, index) => {
$item("#nText").onClick((event) => {
let postTypeValue = itemData.pType
wixData.query("Collection1").eq("_id", itemData._id)
.find()
.then(results => {
let item = results.items[0];
let pIDValue = item.postId;
if (postTypeValue == "R") {
wixLocation.to('/re/' + postIDValue);
} else if (postTypeValue == "L") {
wixLocation.to('/lo/' + postIDValue);
}
})
});
})
}
I suggest trying to use a button instead of the text element. You can usually style the button so it looks the same as the text element you already have. Then instead of setting the onClick, try setting the button's link and target properties.
I am creating a plugin that makes use of the code available from BCFier to select elements from an external server version of the file and highlight them in a Revit view, except the elements are clearly not found in Revit as all elements appear and none are highlighted. The specific pieces of code I am using are:
private void SelectElements(Viewpoint v)
{
var elementsToSelect = new List<ElementId>();
var elementsToHide = new List<ElementId>();
var elementsToShow = new List<ElementId>();
var visibleElems = new FilteredElementCollector(OpenPlugin.doc, OpenPlugin.doc.ActiveView.Id)
.WhereElementIsNotElementType()
.WhereElementIsViewIndependent()
.ToElementIds()
.Where(e => OpenPlugin.doc.GetElement(e).CanBeHidden(OpenPlugin.doc.ActiveView)); //might affect performance, but it's necessary
bool canSetVisibility = (v.Components.Visibility != null &&
v.Components.Visibility.DefaultVisibility &&
v.Components.Visibility.Exceptions.Any());
bool canSetSelection = (v.Components.Selection != null && v.Components.Selection.Any());
//loop elements
foreach (var e in visibleElems)
{
//string guid = ExportUtils.GetExportId(OpenPlugin.doc, e).ToString();
var guid = IfcGuid.ToIfcGuid(ExportUtils.GetExportId(OpenPlugin.doc, e));
Trace.WriteLine(guid.ToString());
if (canSetVisibility)
{
if (v.Components.Visibility.DefaultVisibility)
{
if (v.Components.Visibility.Exceptions.Any(x => x.IfcGuid == guid))
elementsToHide.Add(e);
}
else
{
if (v.Components.Visibility.Exceptions.Any(x => x.IfcGuid == guid))
elementsToShow.Add(e);
}
}
if (canSetSelection)
{
if (v.Components.Selection.Any(x => x.IfcGuid == guid))
elementsToSelect.Add(e);
}
}
try
{
OpenPlugin.HandlerSelect.elementsToSelect = elementsToSelect;
OpenPlugin.HandlerSelect.elementsToHide = elementsToHide;
OpenPlugin.HandlerSelect.elementsToShow = elementsToShow;
OpenPlugin.selectEvent.Raise();
} catch (System.Exception ex)
{
TaskDialog.Show("Exception", ex.Message);
}
}
Which is the section that should filter the lists, which it does do as it produces IDs that look like this:
3GB5RcUGnAzQe9amE4i4IN
3GB5RcUGnAzQe9amE4i4Ib
3GB5RcUGnAzQe9amE4i4J6
3GB5RcUGnAzQe9amE4i4JH
3GB5RcUGnAzQe9amE4i4Ji
3GB5RcUGnAzQe9amE4i4J$
3GB5RcUGnAzQe9amE4i4GD
3GB5RcUGnAzQe9amE4i4Gy
3GB5RcUGnAzQe9amE4i4HM
3GB5RcUGnAzQe9amE4i4HX
3GB5RcUGnAzQe9amE4i4Hf
068MKId$X7hf9uMEB2S_no
The trouble with this is, comparing it to the list of IDs in the IFC file that we imported it from reveals that these IDs do not appear in the IFC file, and looking at it in Revit I found that none of the Guids in Revit weren't in the list that appeared either. Almost all the objects also matched the same main part of the IDs as well, and I'm not experienced enough to know how likely that is.
So my question is, is it something in this code that is an issue?
The IFC GUID is based on the Revit UniqueId but not identical. Please read about the Element Identifiers in RVT, IFC, NW and Forge to learn how they are connected.
So i have a mobile app with 5 tabs one of which is the search tab and i would like that every time i click on the search tab the search comes automatically enabled and the keyboard pops up also meaning that the cursor will be ready in place.I search in the html in the browser and found out that everytime i click on the search bar to write something a new class is added called input-focused so i tried to add this automatically using a methos called enable and which is calling the method searchEnabled but still its not working... any ideas?
<f7-searchbar
#searchbar:enable="searchEnabled"
#searchbar:search="search"
search-container=".search-list"
search-in=".item-title"
></f7-searchbar>
methods: {
search (searchbar, query) {
if (query === '') {
this.results = []
} else {
this.filter.q = query
Search.filter(this.filter).then(({data}) => {
this.results = data
})
.catch((error) => {
console.log('error:', error)
})
}
},
searchEnabled (searchbar) {
searchbar.$inputEl[0].classList.add(['input-focused'])
}
}
I need to create empty folders in each sections (content, Layout, renderings, MediaLibrary, Templates) under Sitecore node programmatically.
Please advise.
A folder in Sitecore is a Item, with for example Template: /sitecore/templates/Common/Folder {A87A00B1-E6DB-45AB-8B54-636FEC3B5523}
So you need code to add a item:
See: How to programmatically populate Sitecore items (Add item and fields)?
https://briancaos.wordpress.com/2011/01/14/create-and-publish-items-in-sitecore/
http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2009/06/ProgramaticallyItems2.aspx
For Example Under the Layout folder you can use a other Template, Template: /sitecore/templates/System/Layout/Renderings/Sublayout Folder
So there are more folder templates, and of course you can create your own, and adding the insert options you need or set a nice icoon in the standard values.
Summarized:
You need privileges to create an Sitecore item, You can use the SecurityDisabler or User Switcher.
Get the parent item.
Create the item with the template you want.
//Get the master database first
Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master");
//Creating a folder under "Renderings". Change path as per requirement
Sitecore.Data.Items.Item parentNode= masterDB.GetItem("/sitecore/layout/Renderings");
//Always get the folder template from this location
Sitecore.Data.Items.Item folder = masterDB.GetItem("/sitecore/templates/Common/Folder");
//Add the folder at desired location
parentNode.Add("Folder Name", new TemplateItem(folder));
As Jan Bluemink said:
public static Item AddFolder(String name, Item Parrent = null)
{
Database myDatabase = Sitecore.Context.Database;
if (Parrent == null)
{
return null;
}
Item kiddo = null;
try
{
Sitecore.Data.Items.TemplateItem FolderTemplate = myDatabase.GetTemplate("{EB395152-CC2F-4ECB-8FDD-DE6822517BC8}");
using (new Sitecore.SecurityModel.SecurityDisabler())
{
kiddo = Parrent.Add(name, FolderTemplate);
//Insert values in fileds
// posibly you need to change language and add version to update;
// let say a template "article with some id {00101010101010-100110-1010100-12323}" with two fiels single line text, multiline text or rich text editor
//kiddo.Editing.BeginEdit();
//try
//{
// kiddo.Fields["Title"].Value = "Title 1";
// kiddo.Fields["Description"].Value = "description 1";
// kiddo.Editing.EndEdit();
//}
//catch
//{
// kiddo.Editing.CancelEdit();
//}
}
}
catch (Exception ex) {
return null;
}
return kiddo;
}
and the call:
Item content = Sitecore.Context.Database.GetItem("/sitecore/content");
Item contentFolder = AddFolder("folder", content);
Item medialib = Sitecore.Context.Database.GetItem("/sitecore/media library/medialib");
Item medialibFolder = AddFolder("folder", medialib);
After the search box is selected, it should expand in all directions to take up the remaining top row of the page in mobile device.I want to use HTML5,CSS3 and simple Javascript(no libraries).
How to implement it?
I got the way.Used javascript to move the search box up.
I passed the textbox as obj in the function below..It works!!!
function findPos(obj) {
var curtop = 0;
if (obj.offsetParent) {
do {
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
curtop=curtop-5;
return [curtop];
}
}