August 02, 2013

Manipulating Kendo's RangeSlider via JavaScript

After dealing with Kendo's Range Slider control this afternoon, I thought it would be worthwhile to post some sample code for dealing with this control on the client side. Manipulating the RangeSlider on the client side is very simple and straightforward, but there isn't good documentation of this control, which has many properties and methods, so you could wind up spending a lot of time grasping at straws.

Kendo's RangeSlider control:

We're creating this control in an ASP.Net MVC project using Razor syntax:
@(Html.Kendo().RangeSlider()

    .Name("RangeSlider")

    .Max((double)Model.RevenueUpperBound)

    .Min((double)Model.RevenueLowerBound)

    .Values(Model.MinVal, Model.MaxVal)

    .Events(events => events.Change(x => "updateVals")))

But after the page is rendered, we want to programmatically change the start and end points via JavaScript. Looking at the object in FireBug, you can see several promising properties and methods like selectionStart, selectionEnd, bind(), etc... But ultimately, you'll just want to new up a JavaScript array containing the two integer values you want to use as the start and end values.

The example below resets our RangeSlider to a start value of 10 and an end value of 111. (Make sure your start and end values are between the upper and lower boundaries of the control itself).
function resetSlider(){

  //Get a handle on our element's RangeSlider
  var slider = $('#RangeSlider').data('kendoRangeSlider')

  //Feed it an array of two numbers.
  slider.value(new Array(10, 111))

}
That's it... As easy as 3.14.

Share |

April 17, 2013

Multitudes / Animal Collective names


Correct multitude naming per animal, in case you were wondering. Back to software-related info next post :)

A Crash of Rhinoceroses. 
A School of Fish. 
A Litter of Pups. 
A Flock of Sheep. 
A String of Ponies. 
A Harras of Horses.
A Pride of Lions.
A Herd of  Elephants. 
A Plague of Locusts. 
A Colony of Ants. 
A Covey of Quail.
A Kindle of Kittens. 
A Leap of Leopards.
A Pod of Seals. 
A Sloth of Bears. 
A Rafter of Turkeys. 
A Pace of Asses.
A Walk of Snipe.
A Gam of Whales. 
A Nest of Rabbits. 
A Gang of Elk. 
A Quiver of Cobra. 
A Dule of Doves.  
A Skulk of Foxes. 
A Dissimulation of Birds. 
A Prickle of Porcupines. 
A Peep of Chickens. 
A Band of Gorillas.
A Business of Ferrets.
A Bale of Turtles. 
A Pitying of Turtledoves. 
A Drift of Hogs. 
A Paddling of Ducks. 
A Siege of Herons. 
A Trip of Goats. 
A Charm of Finches. 
A Cete of Badgers. 
A Squadron of Pelicans. 
A Shoal of Bass. 
An Exaltation of Larks.
A Drove of Cattle. 
A Singular of Boars. 
A Tidings of Magpies. 
A Gaggle of Geese.
A Flutter of Butterflies. 
A Husk of Hares. 
An Unkindness of Ravens. 
A Labor of Moles. 
A Richness of Martens. 
A Cast of Hawks. 
A Knot of Toads. 
A Descent of Woodpeckers. 
A Sounder of Swine. 
A Mustering of Storks.
A Clutch of Eggs. 
A Bouquet of Pheasants.
An Army of Caterpillars. 
A Hover of Trout. 
A Flight of Swallows. 
A Troop of Kangaroos. 
A Clowder of Cats. 
A Watch of Nightingales. 
A Barren of Mules. 
A Shrewdness of Apes.
A Rag of Colts. 
A Bloat of Hippos.  
A Smack of Jellyfish. 
A Mischief of Mice. 
A Congregation of Alligators.  
A Parliament of Owls. 
A Route of Wolves. 
A Host of Sparrows. 
An Ostentation of Peacocks.
A Murder of Crows.

Share |