Last active
August 29, 2015 14:06
-
-
Save dfch/d64cfb6e21892dc8cc26 to your computer and use it in GitHub Desktop.
[NoBrainer] Changing LightSwitch HTML Cascading choiceLists with JayData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// global - or wherever it suits you | |
var ctxApplicationData = "ctxApplicationData"; | |
// somewhere at the very start of the application | |
$(function () { | |
var svcApplicationData = msls.application.rootUri + "/ApplicationData.svc"; | |
$data.initService(svcApplicationData) | |
.then(function (context) { | |
// manage your data through context with JSLQ | |
console.log(svcApplicationData + ": we are here..."); | |
ctxApplicationData = context; | |
}); | |
} // document.ready() | |
// AddFuncensteinScreen.lsml.js | |
myapp.AddFuncensteinScreen.created = function (screen) { | |
// we add a change listener to the parent control | |
screen.addChangeListener("FuncomaticListControl", addChangeListenerFuncomaticListControl); | |
} | |
function addChangeListenerFuncomaticListControl(e) { | |
value = e.currentTarget.FuncomaticListControl; | |
console.log("FuncomaticListControl: '" + value + "'"); | |
var dataChoices = new Array(); | |
function renderData(_list) { | |
_list.forEach(function (item) { | |
console.log(item.Name); | |
dataChoices.push({ value: item.Id, stringValue: item.Name }); | |
}); | |
var ChildDropDown = e.currentTarget.details.screen.findContentItem("FuncyChildListControl"); | |
ChildDropDown.choiceList = dataChoices; | |
ChildDropDown.dispatchChange("choiceList"); | |
ChildDropDown.dispatchChange("value"); | |
} | |
ctxApplicationData.FuncyItems | |
.filter(function (e) { | |
(e.Funcomatic.Name == value) | |
}) | |
.orderBy("it.Name") | |
.map(function (e) { | |
return e | |
}) | |
.toArray(renderData); | |
} // addChangeListenerFuncomaticListControl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment