Sitecore adding field labels to name value list - sitecore

I am trying to display field titles above the appropriate columns in a name value list in Sitecore.
e.g. So instead of this
The name value list would look like this
Is there an easy method of achieving this apart from writing a custom control?

There is no out of the box support for applying a label to the values in a name value list, as #jammykam mentioned.
Since what you are storing would not typically be handled as key/value data, the name value list type might not be the best fit for what you are doing - think what you would have to do if you needed to add extra information e.g. title. I would suggest creating a simple template for 'person details' and then add 'people' items as sub-items of your existing item.

Seems like you want to give the authors a hint regarding the input fields and the best way to do that is using the "Short Description" field in "Help" section of the template under Standard Values. You can possibly enter something like as a hint.
A less optimal option would be to set up standard values for that field so the authors always have a value that suggests the type of input value for key and value.

Related

How to add insert option Programmatically in C# Sitecore

Insert option is not coming, can anyone help on this how I can programmatically insert option with item when we do not have insert option in _standardValue of template
When you create/edit the item from code, you can at the same time write to the Insert Options field, aka __Masters as field name, aka Branches as code constant, just as any other field. The field contains a pipe-separated list of template ID's. For example, like this:
item[Sitecore.FieldIDs.Branches] = "{TemplateId1}|{TemplateId2}|{...}";
// above is equivalent to item["__Masters"] = "...";
As you say, this will write a local value on the item being edited, and will therefore break any inheritance of the insert options that may be defined in __Standard Values. But in some scenarios this is actually better than having it on __Standard Values.

Predicting the placeholder for a dynamic placeholder

I am using the Dynamic Placeholders from Fortis, but need to setup a page template where the Dynamic Placeholders contains renderings. I am setting the page template up, by setting layout detail on the standard values of the page template.
I have been unable to succeed in this, since the dynamic placeholder is postfixed by a GUID which is generated. Is there a way to predict this GUID? According to the documentation, the GUID is generated using the following logic:
Dynamic Placeholders simply use the rendering ID to create a unique placeholder name. If more than one dynamic placeholder with the same name is in a rendering it will also append on an incrementing number
I tried another approach, by using a home brewed dynamic placeholder library, which just prepended the dynamic placeholder with a sequential number, e.g. row1, row2, row3. But this approach makes the content editors unable to move rows in the experience editor, since the content inside the row is tied to a fixed number, which changes when the rows are moved.
As this question have been answered on sitecore.stackexchange.com, I want to bring the answer here as well. Big credit to Richard Seal and Thomas D.
Thomas D:
You can try to open the standard values item with the Experience Editor and add the renderings you like.
Richard Seal:
This is an alternative to the method mentioned by Thomas D.
The Fortis solution uses the UID for the rendering attached to the placeholder key that you enter. You can get this by changing to Raw Values view and copying the xml out of the renderings or final renderings field.
Find the rendering that contains your placeholder. There will be an xml element like this:
<r id="{CA76EB6F-2934-4B8A-BB6A-508A8E44A7C5}"
ph="body"
uid="{0FD41EBD-43CF-4647-8A0F-F1F1D2E00CCD}" />
There may be other fields too. The 2 that are important are id, which is the item id of your rendering item and uid, this is the unique rendering id that is added to your placeholder key.
The key is built like this: string.Format("{0}_{1}", placeholderName, renderingId);
So if you have a placeholder key called title, the key for the above xml snippet would be: title_{0FD41EBD-43CF-4647-8A0F-F1F1D2E00CCD}

How to make a search based on get_field_gender label?

Well, this might be a bit odd, but I was wondering if it is possible to make a search based on the label for choiceFields rather than the stored database value.
I have an app that when the user searches for a vehicle of type truck, the query can't retrieve results because the value stored in the database is tru, although choiceField label is truck. The same goes for gender female is fem, for example.
I could go around this problem with alternative ways, but I was wondering if Django had this implemented somehow.
I think you should consider changing the search functionality to search with the shortened name. You can still display the label on the front-end: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#Examples

Add Dropdown to infragistics WebDataGrid in Edit mode

I have two issues:
I have a complex object with Id and Text underneath. For display, I am using TemplateDataField with eval function. Can I bind the complex object to a BoundDataField?
The reason behind binding the complex object to BoundDataField is, I need to make it editable grid. I could not find any documentation or samples which uses Template field, and make that column editable. (I agree it might not be possible.) Now I need to put a dropdown, where user selects a value and I can assign it to the id field of my complex object. I am able to put a dropdown (using EditorProviders) to a bounddatafield, but how can I do it for the template data field described above?
Here is a link to the samples of Editing WebDatagrid: Controls & Application Samples
When using a TemplateDataField you are specifying what you want to use as the template and you can put an editor in that Field. Note that if you do put an editor in that field, you need to handle updates to the grid's value or list that your grid is bound to.
Note that if the values in your drop down have an id associated with them and that can be the value of the grid cell it would be better to use the DropDownEditorProvider with the grid having a bound field where that field is the id of the item that you are selecting.

What's the best way to represent many booleans in a django model?

I have a model which represents the user's display preferences. Just about all of these preferences are boolean values. Instead of having 50 boolean columns, is there a better way to go about this? In the future when I want to add a new item, I don't want to have to add a new column in my database.
If you have that many booleans and are anticipating adding more, you should not be using columns, but entries.
Then when you need to look up "User wants emails", just search for UserPrefs.objects.get(User=user, Preference=Preferences.objects.get(name="wants email")).
User_Table:
User
username
etc
Preferences_Table:
name
description
etc
UserPreferences_Table:
User (FK_User)
Preference (FK_Preferences)
Setting (Boolean)
Depending on your setup, you may be able to omit the Setting field in the UserPreferences table and simply use the existence of an entry for that User/Preference as a True and the lack of one as a False.
You could also use a bitmap. You only need single char field in you database. Somewhere in your app you store a list of preferences, pref1, pref2, pref3 ... and in the bitmap filed you store a sequence of 1's and 0's that correspond to the preferences.
For example 101 means pref1=yes, pref2=no, and pref3=yes and 011 means pref1=no, pref2=yes, and pref3=yes.
You could make this reusable by creating a new model field type for bitmaps.
" In the future when I want to add a new item, I don't want to have to add a new column in my database."
In this case, you'll want to add a row.
You have a table with the domain of possible setting Names. 50 rows.
You have a table of actual settings. User, Setting Name, Setting Value.