Sitecore Speak UI : How to manipulate column value of List Control before displaying in list . - sitecore

I am working in speak UI . I have list of items to display in list . But before that i have to check one column value and need to manipulate this value with a Icon to display . How can I implement this change in SpeakUI . Please help

Simple option:
If the data you receive is directly relateable to the icon you want to display:
Set your DataSource on your ListControl to a ListControl Parameters item with your ColumnField items underneath (as outlined in Sitecore doco or other blogs). In the HTMLTemplate field for your column, you can use the value as the source of an image or CSS class with background image style.
<img src="{{YourField}}" />
or
<span class="{{YourField}}"></span>
where your span class styles your icon.
More complex but customisable:
I'm not sure which datasource you are using, but I am a fan of the JsonDataSource by Anders Laub as it's very simple to use and customise (you only need to add 2 small files).
To your SPEAK renderings you add your JsonDataSource, and ListControl with Items property: {Binding JsonDataSource.Json} (and DataSource as required)
Then in the javascript for your page (defined in your PageCode rendering) you can add items to this datasource and customise as required:
jQuery.ajax({
type: "GET",
dataType: "json",
url: "/yourApiCall" + params,
cache: false,
success: function (data) {
var total = 0;
for (var i = 0; i < data.YourItems.length; i++) {
app.JsonDataSource.add({
Col1: data.YourItems[i][0],
Col2: data.YourItems[i][1],
Col3: data.YourItems[i][2]
});
}
},
Where Col1, Col2, and Col3 are the names of your columns, and YourItems is the array of items you are receiving from your ajax call.

Related

Webix layout as template

I'm new to Webix and trying to create a list or dataview where users can add and remove itens. (font files this time)
For such i defined one "add" button and one list where previously added items are displayed.
My plan was to put an label and a exclude button into each item of the list with the components Webix already provides but to my surprize the template property of data components aparentily can't be definied with ui objects itself.
There is some way to do it?
Somethink like it:
webix.ui({ id:'stage', rows:[
{ view:"button", type:"icon", icon:"plus", label:"Add Font", autowidth:true, click:AddFont },
{ view:"dataview", id:"fnt_list", data:fonts(), width:300,
type:{ width:300, height:150, template:function(fnt)
{
return webix.ui({cols:[
{view:"label", align:"left", label:fnt.fileName },
{view:"button", type:"icon", icon:"trash", label:"Exclude", align:"right", autowidth:true }
]});
}}
}]});
I know it can be made with the layout component alone but i really would like to do it with one of the data components because of the paging feature they have.
While it possible to create a separate instance of webix UI for each row, it is overkill for your task, just use HTML markup in the template. Something like next
{ view:"dataview", css:"fonts", id:"fnt_list", data:fonts, width:300,
type:{
width:300, height:150,
template:"#fileName# <i class='fa fa-trash-o'></i>"
},
working snippet - https://snippet.webix.com/dvbdt6st
If you still want to have real UI widgets inside of dataview items, check
https://docs.webix.com/desktop__data_layout.html
and
https://docs.webix.com/desktop__active_content.html

set List filters in ExtJS grid dynamically from response

I am trying to set(check) List filters of a grid column dynamically
from response.
I am able to set them but when I open the menu of the corresponding
filter and setting some other combination of data to filter
dynamically it is getting selected and later cleared.
Is the code am using below for setting filters is right?Need help.
var gridFilter = currentGrid.columns[i].filter;
gridFilter.setActive(true);
gridFilter.filter.value="SELECTED,REJECTED"; //putting static data for now
gridFilter.filter.setValue(["SELECTED", "REJECTED"]);
Best way to add and Edit filter for ExtJs is FilterBy method:
grid.getStore().filterBy(function(rec, id)) {
return (rec.get("DynamicRecName")=="DynamicFilterRecord");
}
If you want to edit existing then just remove current filters:
grid.getStore().clearFilters()

Sitecore SPEAK UI set selected row of ListControl

I have a SPEAK UI dialog with a ListControl bound to a custom JSON datasource. This works and the ListControl is correctly populated. My JSON data looks something like this:
[
{
"itemId":"{BA26159A-194D-4A3C-9D1A-DA9472F11BE0}",
"selected":true
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E69}",
"selected":false
},
{
"itemId":"{E651D0CD-0E7E-4903-8E26-0D1D5A168E70}",
"selected":false
}
]
Is there a way to ensure the relevant row of the ListControl is selected ("selected":true) when the dialog loads?
You can set the ListControl's selected item ID like this: this.MediaResultsListControl.viewModel.set({selectedItemId:"ITEMID"})
(Sitecore.Speak.app instead of this during dubuging in the console)
If you call this.MediaResultsListControl.viewModel.selectedItemId() you can see the selected item has been set by the above method.
Wondering on page load, if you can set the ListControls selected item id, from the page code manually using this method?
Looking at the JS for the list control. It calls this on click of a row. Wonder if you can replace this to trigger selected row?
selectRow: function (row, rowModel) {
this.$el.find(".active").removeClass("active");
row.addClass("active");
this.model.set("selectedItem", rowModel);
this.model.set("selectedItemId", rowModel.get("itemId"));
},

Orchard container without creating list tags

I am using Orchard to create a table-like layout. I have defined two content types: 'Row' and 'Column'. To allow items of the type Column to be added to a Row I added the 'Container' part to the Row and 'Containable' to the Column.
All works fine, the columns show up in the row they were put in, however Orchard renders list tags around my columns which mess up my layout. Is it possible to prevent these list tags from being rendered? I checked out the source of ContainerPartDriver.cs but the 'listShape' seems to be baked in, however I hope someone can prove me wrong.
For now I am retrieving the container items and displaying each one in the view itself.
#{
var contentManager = WorkContext.Resolve<IContentManager>(); ;
var container = (ContentItem)Model.ContentItem;
var query = contentManager
.Query(VersionOptions.Published)
.Join<CommonPartRecord>().Where(x => x.Container.Id == container.Id)
.Join<ContainablePartRecord>().OrderByDescending(x => x.Position);
}
#foreach (var item in query.List())
{
#Display(contentManager.BuildDisplay(item, "Detail"));
}

Disabling/Enabling a oracle apex Tabular Form Attribute based on the value selected in another attribute

I have a tabular form attribute which is a select list with static values Yes/no and another 2 attributes of Date and display.
My requirement is when i select "No" from the Select List, Date attribute should be enabled and Display attribute should be Disabled and If "Yes" From select list Display attribute should be enabled and Date attribute should be Disabled.
Dynamic Action:
Created a Dynamic action:
event = Change
Selection Type = Jquery selector
Jquery selector = `select[name='f06']`
Action = Execute javascript Code
var el = this.triggeringElement.id;
var row = el.split("_")[1];
if ($v(el) == "N") {
// disable the field
$x_disableItem("f04_" + row, true);
}
else {
// enable the field
$x_disableItem("f04_" + row, false);
}
Dynamic action Working perfectly for already created Rows, But not while i am trying to add new Row by selecting Add row.
https://apex.oracle.com/pls/apex/f?p=38210:LOGIN_DESKTOP:115699939041356
App 38210. Apex 4.2.6
Workspace/username/password : nani4850
Kindly help me out experts!!
Adding a blank row involves a partial page refresh, so the Event Scope of your dynamic action needs to be changed from Static to Dynamic in order for the change event handler to remain bound to the triggering elements.
You'll now find you have problems submitting new records, but if you're having difficulty, that's for another question!