Titanium search view nor sorting out - titanium

I 'm using Android Titanium Appcelerator.
I had created a search bar for a tableview but it does not sorting the table values, please help:
var search = Titanium.UI.createSearchBar({
showCancel : false,
});
TableView = Ti.UI.createTableView({
search : search,
searchHidden : true,
filterAttribute : 'filter',
});
And I have added filter = contents; inside my rowview.

This is the basic code. I append all the text I want to search on into the filter of the tableRow definition. I then set the filter attribute of my tableROW to the filterAttribute of the tableVIEW.
var tableRow = Ti.UI.createTableViewRow({
height : '70dp',
layout : 'vertical',
filter : filterByThis1 + ' ' + filterByThis2
});
var search = Ti.UI.createSearchBar({});
var tableView = Ti.UI.createTableView({
filterAttribute : 'filter',
search : search
});

Related

Update Owl Carousel 'Page' on Event + Bootstrap Tabs

I am trying to use both Owl Carousel and Bootstrap to create tabs that have a continuous carousel for the tab navigation. I also want these tabs to cycle automatically.
Here is a visual reference:
And here is a fiddle:
https://jsfiddle.net/j28md74n/
The main JS that I'm using (i've commented out the areas where i'm stuck):
var owlTab = $(".tab-carousel.owl-carousel");
owlTab.owlCarousel({
navigation: false,
dots:true,
navigationText: [
"<i class='fa fa-angle-left'></i>",
"<i class='fa fa-angle-right'></i>"
],
items : 4,
lazyLoad : false,
autoPlay : false,
draggable: true,
stopOnHover : true,
paginationSpeed : 1000,
transitionStyle:"fade",
responsive: true,
loop: true,
rewindNav: true,
});
$( document ).ready(function() {
if ($('.tab-carousel.owl-carousel').length){
$('.tab-carousel.owl-carousel .owl-item').attr("role", "presentation");
$('.tab-carousel.owl-carousel .owl-item:first-child').addClass('active');
};
$( ".tab-carousel.owl-carousel .owl-item" ).click(function() {
$( ".tab-carousel.owl-carousel .owl-item" ).removeClass('active');
$(this).addClass("active");
});
});
var tabCarousel = setInterval(function() {
var tabs = $('.tab-carousel.owl-carousel .owl-item'),
active = tabs.filter('.active'),
next = active.next('.owl-item'),
toClick = next.length ? next.find('a') : tabs.eq(0).find('a');
var indexNum = active.index();
console.log(indexNum);
if (indexNum > 2){
$('.owl-pagination .owl-page:eq(0)').removeClass("active");
$('.owl-pagination .owl-page:eq(1)').addClass("active");
// Here's where I want to change the owl carousel 'page'...to page '2'
};
if (indexNum <= 2){
$('.owl-pagination .owl-page:eq(0)').addClass("active");
$('.owl-pagination .owl-page:eq(1)').removeClass("active");
// Here's where I want to change the owl carousel 'page' ...to page '1'
};
toClick.trigger('click');
}, 6000);
I'm able to accomplish most of what I want, however, when the '.active' '.owl-item' is the 5th item or above (i.e. on the another owl carousel 'page') that the owl carousel 'page' updates as well. There are 4 items per owl carousel 'page.' Currently, the way I have it, if the '.owl-item' cycles through past the 5th item, the owl carousel page stays on the first one.
Thanks in advance for any insights!
Not sure, but i think the problem is the way you're determining the indexNum..
I had to reconfig how to find current index, but this could work.
working example.
function animationLoop() {
// Increment Active IDX each Loop
activeIdx++;
// Reset Active IDX if > tabs.length
if ( isEnd( activeIdx, tabs ) ) setIdx( 0 );
console.log("Current IDX", activeIdx);
// Click on the current active index
$(carouselItems[ activeIdx ]).find('a').trigger('click');
// console.log("Clicking This", carouselItems[ activeIdx ].innerText);
// Reset Loop
setTimeout(animationLoop, 3000);
}

Move the value along with the handle in dijit/form/HorizontalSlider

Currently i am getting the values upon sliding but I want to display the values along with the handle in dojo horizontal slider.
I am creating the slider like this
var slider = new HorizontalRangeSlider({
name : "slider",
value : startValue,
//starting and end values to the slider
minimum : endValue,
maximum : endValue,
intermediateChanges : true,
showButtons : false,
onChange : lang.hitch(this, "setValues")
}, this.slider).startup();
var sliderLabelsRule = new HorizontalRule({
container : "topDecoration",
style:"height:5px",
count : 2,
numericMargin: 1
}, this.sliderRule);
this.sliderLabelsRule.startup();
//create the labels object
var sliderLabelsTop = new HorizontalRuleLabels({
container : "topDecoration",
style : "font-size: 14px;",
//array that contains the label values
labels : array,
}, this.sliderLabelsTop);
sliderLabelsTop.startup();
And the template is like this
<div>
<div data-dojo-attach-point="slider">
<div data-dojo-attach-point="sliderRule"></div>
<ol data-dojo-attach-point="sliderLabelsTop"></ol>
</div>
</div>
Now i have to display the value upon sliding the slider rule just below the slider handle, How to do this in dojo?
We can make use of the HorizontalRangeSlider attach points and we can place the value that you want to show by placing there.
HorizontalSRangeSlider has two attach point sliderHandle and sliderHandleMax,we can place the value there like this,
this.horizontalSlider = new HorizontalRangeSlider({
name : "slider",
value : this.sliderMinMax,
minimum : this.sliderMinMax[0],
maximum : this.sliderMinMax[1],
intermediateChanges : false,
showButtons : false,
onChange : lang.hitch(this, "callOnchange")
}, this.slider);
this.horizontalSlider.startup();
this.horizontalSliderRule = new HorizontalRule({
container : "topDecoration",
style:"height:5px",
count : 2,
numericMargin: 1
}, this.sliderRule);
this.horizontalSliderRule.startup();
this.horizontalSliderRule.sliderHandle.innerHTML = value //your value to show

Dojo gridx: using "onAfterRow" disables "onCellWidgetCreated"?

When creating a gridx, I use the following column definition to insert an Edit button in to the last cell of each row:
var editColumn = { field : 'Edit', name : '', widgetsInCell: true,
onCellWidgetCreated: function(cellWidget, column){
var btn = new Button({
label : "Edit",
onClick : function() {
console.log('Do stuff here');
});
btn.placeAt(cellWidget.domNode);
}
};
columns.push(editColumn);
var grid = new Grid({
cacheClass : Cache,
store : store,
structure : columns,
modules: ["gridx/modules/CellWidget"]
}, 'gridNode');
grid.body.onAfterRow = function(row){
...do stuff on the row here
};
Whne I include the onAfterRow function the row processing happens but the OnCellWidgetCreated does not. Each function seems wo work in absence of the other. Any suggestions on how I can: (1) format the rows according to row data AND (2) insert the button widgets in the last cell of each row?
Ok, solved it. Rather than assign the grid.body.onAfterRow, the way that worked for me was:
aspect.after(grid.body,'onAfterRow',function(row){
key = row.id;
if ('anulada' in row.grid.store.get(key)){
if(row.grid.store.get(key).anulada == true){
row.node().style.color = 'gray';
}
}
},true);
You need to require "dojo/aspect".

How to dynamically add columns to kendo grid with inline edit option

I have a column array object which is bound to columns property of kendo grid. If I add a command in the array, the button appears but the edit event is not firing.
Also in edit mode I need to make the checkboxes in each column as enabled and update it based on the column name.
I am adding the columns using below code and biding to columns property of kendo grid.
var titleDefs = [
"User Name", "Admin", "Print"
];
// Field Definition
var fieldDefs = [
"UserName", "Admin", "Print"
];
var columnDefs = [];
for (var i = 0; i < titleDefs.length; i++) {
if (i == 0)
columnDefs.push({
title: titleDefs[i], field: fieldDefs[i],
});
else
columnDefs.push({
title: titleDefs[i], field: fieldDefs[i], template: '<input id=chk' + fieldDefs[i] + ' name=chk' + fieldDefs[i] + ' type="checkbox" #= ' + fieldDefs[i] + ' ? "checked=checked style=display:block disabled=disabled" : " style=display:none" # ></input>',
});
}
columnDefs.push({ command: "edit", title:"", width:"100px"});
Please help me in this.
While defining the column in the column list, you will be having the property in your datasource based on what you will be making it editable ie YourProperty,using this property you can bind the checked property like below.
columnList = [{ title: "", width: "30px", template: "<input class='chkEmail' id='chk_#= DocumentGUID #' type='checkbox' data-bind='checked: YourProperty' #= YourProperty? checked='checked' : '' #/>", groupable: false}]

Spotify API models.SEARCHTYPE.SUGGESTION not working

As the user types an artist name to search we want to display a drop-down list of suggestions based on what the user has typed so far.
For example, if the user has so far typed "Bob Dy" we would like to list "Bob Dylan","Bob Dylan & The Band", and "Willie Nelson;Bob Dylan" just like the standard Spotify Radio App does.
We are trying to use the Search API call to retrieve the list of artists to display. I assume we want to use the models.SEARCHTYPE.SUGGESTION option however when using that option we always get an empty list. The models.SEARCHTYPE.NORMAL option does return a list when there is an exact match such as in the case of entering "Bob" or "Bob Dylan" but not "Bob Dy".
Could you please tell us what we are doing wrong?
The documentation we are using is:
http://developer.spotify.com/download/spotify-apps-api/reference/833e3a06d6.html
Here is the code we are using:
var search = new models.Search('artist:"Bob Dy"');
search.localResults = models.LOCALSEARCHRESULTS.IGNORE;
search.searchArtists = true;
search.searchAlbums = false;
search.searchTracks = false;
search.searchPlaylists = false;
search.pageSize = 10;
search.searchType = models.SEARCHTYPE.SUGGESTION;
//search.searchType = models.SEARCHTYPE.NORMAL;
search.observe(models.EVENT.CHANGE, function() {
console.log('[models.EVENT.CHANGE observe]', search.artists);
});
Seems like the normal search input in Spotify doesn't support auto suggest for prefixed searches like "artist:Bob Dy". The code below works for me though.
var search = new models.Search('Bob Dy', {
'localResults' : models.LOCALSEARCHRESULTS.IGNORE,
'searchArtists' : true,
'searchAlbums' : false,
'searchTracks' : false,
'searchPlaylists' : false,
'pageSize' : 10,
'searchType' : models.SEARCHTYPE.SUGGESTION
});
search.observe(models.EVENT.CHANGE, function() {
search.artists.forEach(function(artist) {
console.log('[models.EVENT.CHANGE observe] - Found artist %s',
artist.name);
});
});
// Do the search, nothing will be fetched
// if this row is not executed.
search.appendNext();