PeterBlum SelectedIndexCondition Not Equal functionality - c#

Right now we are using the PeterBlum SelectedIndexCondition to control whether or not some controls are displayed using the following snippet:
PeterBlum.DES.MultiFieldStateController fsc = new PeterBlum.DES.MultiFieldStateController();
PeterBlum.DES.SelectedIndexCondition cnd2 = new PeterBlum.DES.SelectedIndexCondition();
cnd2.Index = desiredIndex
cnd2.ControlToEvaluate = ControlToEvaluate//ListBox, dropdown, etc
fsc.Condition = cnd2;
I'd like to be able to achieve this same functionality except to fire when the desired index IS NOT set. I cannot simply create a bunch of Conditions for each index other than the one I specify due to the way this is dynamically being done in my application.
Thanks in advance,
Ben

You will probably get better results if you post your question to Peter's Yahoo Forum. In my experience, he will get back to you very quickly with a good answer.

Related

Categorised multi-select dropdown list in Sitecore

As an Umbraco developer, I am fairly new to Sitecore and so far have been fairly annoyed that some of the functionality that can easily be added in manually in Umbraco seems to be extremely convoluted and poorly documented in Sitecore.
Essentially, I have multiple language sites:
English
French
German
Beneath each of these sites are a set of articles:
English
Article 1
Article 2
French
Article 3
Article 4
What I want to achieve is a property in the back end that is categorised by country and allows the user to select multiple articles from across different language sites.
So, for example, I could select Article 1 and Article 3. Ideally the select control would look something like this with the countries as bold, unselectable categories and the options beneath being subject to standard multi-select behaviour.
Is anyone aware of how this may be achieved in Sitecore? Alternatively does anyone know of any Sitecore marketplace plugins that would allow me to achieve this as, so far, the documentation and literature on the web regarding this has been lacking.
Any help or pointers would be greatly appreciated.
You can achieve something like that with a TreeList. It will look like a tree, so not exactly as you wanted but the functionality that you need can be done. The TreeList can be tweaked with the "source" value to show a part of the Sitecore tree, have certain items unselectable, and so on..
A good resource can be found here.
In your case, use the Datascource and ExcludeTemplatesForSelection/IncludeTemplatesForSelection options for the source query.
I can get you most of the way there with a coded data source. If you create a class that inherits from IDataSource, you can fit it with whatever you want. What I can't get you is denying the user selecting the the bold countries.
Here is an article from John West talking about it and the code below is code I am currently using. I am using this code in a rendering property, so you will see many references to renderings. But all you are looking for is to return an array of Items.
Then in the datasource, you specify the word "code:" followed by you class name "," the assembly name.
code:Sitecore.Sharedsource.Data.FieldSources.CustomFieldDataSource,Sitecore.Sharedsource
public class GetStyles : IDataSource
{
public Item[] ListQuery(Item item)
{
bool flag = !string.IsNullOrWhiteSpace(Context.RawUrl) && Context.RawUrl.Contains("hdl");
if (flag)
{
string renderingId = FieldEditorOptions.Parse(new UrlString(Context.RawUrl)).Parameters["rendering"];
if (!string.IsNullOrEmpty(renderingId))
{
ItemUri renderingItemUri = new ItemUri(renderingId);
var containers = DependencyResolver.Current.GetService<IPresentationRepository>().GetStylesItem(renderingItemUri.ItemID, item);
if (containers == null)
return new Item[0];
return containers.Children.ToArray<Item>();
}
}
var result = new Item[0];
return result;
}
}

How to keep all date selection in calendar?

I've created a code that read dates from a database and put them into the Calendar control. All working good, but if the user select a date in the Calendar, after the population, all the date selected through code disappear. There's another way to flag the date that are previously added from the database population?
public void setFixturesControl()
{
Database.m_dbConnection.Open();
string query = "select * from date";
SQLiteCommand input = new SQLiteCommand(query, Database.m_dbConnection);
SQLiteDataReader reader = input.ExecuteReader();
while (reader.Read())
{
if (MainWindow.AppWindow.League.SelectedItem.ToString().Equals(reader["caption"].ToString()))
{
MainWindow.AppWindow.Calendar.SelectedDates.Add(DateTime.Parse(reader["data"].ToString()));
}
}
Database.m_dbConnection.Close();
}
There's a way to prevent the dates disappear after a user click? Or something that allow me to recognize the dates added by database population? Thanks.
After a long search on the net and a large documentation on the Calendar class, I could see two things:
To get what I want I have to take advantage of a custom control
Try to act via code by creating a delegate, but this is not really a
simple thing
I ran then in the first point, in particular, from the post of David Veeneman, it addresses exactly my problem.
The final result will be like this:
Exactly what I want.
In the post it is all documented, so it would be pointless to do a copy paste here. Thank this member that for me at least was able to solve a failure in the control of Microsoft. Unfortunately I am increasingly convinced that WPF is still immature and that still requires a bit 'of years to complete. I hope my answer is help, if anyone manages to solve the problem in a more elegant, well it responds well. Thank You.

Grouping identical labels and changing text all together - c# / Javascript

I have a asp.net C# MVC Razor view that allows the user to change units for input fields from metric to imperial. There are about a dozen labels that all need to be changed at the same time to the same text, no exceptions ("mm" => "inch" and visa verse).
Since the dot net framework requires each element to have unique ID fields I'm trying to find another way to group them all together and change them on the client side.
It seems silly to give each one a unique ID and call each one individually in a if/then statement to switch measurement systems when they are identical. There has to be a better way.
I attempted to use #ViewBag but I found that javascript can only read the value and can't change it on the client side.
#Html.Label("display_units", "mm", new { id = "lbl_units" })
Thanks for your help and suggestions.
Give your labels a common css class like "display-units". Then from Javascript code, you can use jQuery to find all labels of that class and change the text:
$(".display-units").text('mm');
KnockoutJS was written to solve this kind of problem, ie, binding your viewmodel to your view.

CRM 2011 - Display all entities in option set

I just started working with Dynamics CRM 2011 and need to do some tasks but I simply don't know how. Really hope you can help me with this.
I need to set the values for a picklist(option set) through code behind, it should display all published entities in the solution everytime the form of my custom entity is loaded.
I've searched the web and all I found was the next piece of code, but I absolutely have no idea what to do with is (yeah, I'm newbie, didn't you notice):
RetrieveAllEntitiesRequest req = new RetrieveAllEntitiesRequest();
req.EntityFilters = EntityFilters.Privileges;
req.RetrieveAsIfPublished = true;
RetrieveAllEntitiesResponse resp = (RetrieveAllEntitiesResponse)service.Execute(req);
I tried to do the same with some JScript samples I found on the SDK but I still couldn't manage to insert the values into the picklist. Please give a hint or something. Thanks.
In that case, I think, you should create an entity and put a lookup on form instead.
I've never seen using a picklist for dynamic data, I use them only for static.
They're like global enums.
But, they say about addOption at MSDN Xrm.Page.ui Control methods web page.
Have you tried this one?

jquery datatables fnfilter + script performace

I am away from my development workstation so I thought I'd ask this in hopes of getting an answer when I try it tomorrow. I have a two part question relating to a web application i built using c# jquery and jquery datatables:
1) I know that we can set the value of fnfilter as metioned on their page using something like:
var oTable;
$(document).ready(function() {
oTable = $('#example').dataTable();
/* Filter immediately */
oTable.fnFilter( 'test string' );
} );
however is there a way to retrieve the value entered by the use in the search bar? I was thinking along the lines of
var aContainer= oTable.fnFilter()
or
var aContainer= oTable.fnFilter($(this).html())
2) My application has to retrieve values from another source on the web. These are the value displayed in the datatable. Most of my processing(counting, etc..) is done client side and has drastically slowed down generating the web app. Does anyone know of any suggestions to increase performance of client side scripts specifically datatables?
If your datatable is really instantiated as oTable = $('#example').dataTable(); then doing this:
var textEntered = $('#example_filter input:text')[0].value;
Should return whatever the user entered on the field for filtering.
In answer to #1, you can get the value of the text entered into the search box by doing
// Assume the table's id attribute is 'blah'
var search_string = $('#blah_filter>input').val();
As far as #2, have you considered server-side processing of the data and sending the result to the client?
This article
might give you a big help if you decide to write server side code. Now researching it myself (and not looking forward to implementing custom filtering!).

Categories