Not sure if it is the same issue as mentioned in T511 , but I am trying to autopopulate two fields based on what the user chooses from a dropdown within a dynamic matrix. The use case is the end user choosing how many NICs to add to a server and specifying the VLAN and IP address. I would like the subnet mask and gateway to autopopulate since they will always be the same for that VLAN.
As a test I tried just matching on the first possible choice in the dropdown. The page loads fine, but when choosing the option from the dropdown, the mask field does not change. My trigger code is written as follows:
triggers: [
{
type: "setvalue",
name: "vlan",
operator: "equal",
value: "CitrixPres",
setToName: "mask",
setValue: "255.255.255.0"
}]
The dynamic matrix code is as follows:
{type: "matrixdynamic", name:"nics",title:"Network Cards",
columns: [{name:"vlan",title:"VLAN",cellType:"dropdown"},{name:"ipaddress",title:"IP address",cellType:"text"},{name:"mask",title:"Subnet Mask",cellType:"text"},{name:"gateway",title:"Gateway",cellType:"text"}],choices:[{value:"CitrixPres"},{value:"CitrixServer"},{value:"ClinicalServer"},{value:"ClinicalStations"},{value:"Facilities"},{value:"IT_EHR"},{value:"ITAdmin"},{value:"ITServer"},{value:"LoadBalance"},{value:"Management"},{value:"Pacs"},{value:"PharmacyCam_VL"},{value:"Security"},{value:"ServerDMZ"},{value:"TSM_Network"},{value:"VDI"},{value:"vlan1060"},{value:"vlan1688"},{value:"vlan6"},{value:"Vocera"},{value:"xEpicServer"},{value:"YRCC"}],rowCount:1,addRowText:"Add NIC",removeRowText:"Remove NIC"}
Will the trigger not work with the dynamic matrix or am I not referring correctly to the vlan and mask fields in my trigger?
Thanks.
Hello.
Unfortunately, setvalue trigger doesn't work in this way. The only way to achieve the needed behavior is to use onMatrixCellValueChanged event right
now.
Here is the example: https://plnkr.co/edit/8grDEkDAHMS4HEIXvoUS?p=preview
Thank you,
Andrew
SurveyJS Team
Thanks Andrew,
I was able to get it to work the way I wanted using the example on Plunker. However, I failed to mention that the form is just a little bit more complex. The dynamic matrix question is imbeded inside of a dynamic panel. I am assuming this changes the way I refer to the column of the dynamic matrix. I have included a screenshot of the panel and below is the JSON code for the panel and the included dynamic matrix question.
var json = {
title: "New Server Build", pages:[
{questions: [
{type: "text", name:"request", title: "Request number:"}
]},
{title: "Server Specs",questions:[
{type: "text", name: "projname", title: "Project Name",isRequired: true},
{type: "paneldynamic",name:"serverspecs",title:"Server Requirements",templateElements:[
{type: "dropdown", name: "os", title:"Operating System", choices:["Windows Server 2012","Windows Server 2016","Unix/Linux"],startWithNewLine:false,isRequired:true},
{type: "text", name:"unixflavor", title:"Specific Unix/Linux Operating System", visibleIf: "{panel.os}='Unix/Linux'", startWithNewLine:false,isRequired:true},
{type: "dropdown", name:"cpus", title:"Number of CPUs",choicesByUrl:{url:"num",valueName:"num"},startWithNewLine:false,isRequired:true},
{type: "dropdown", name:"memory", title:"Memory(in GB)", choicesByUrl:{url:"nums",valueName:"mem"},startWithNewLine:false,isRequired:true},
{type: "text", name:"servername", title:"Server Name",isRequired:true},
{type: "dropdown", name:"cluster",title:"VCenter cluster",isRequired:true,startWithNewLine:false,choices:["noc-AMP-CORE","noc-EpicOLTP","noc-EpicPres","noc-Production","noc-Test","noc-VDI"]},
{type: "matrixdynamic", name:"nics",title:"Network Cards",
columns: [{name:"vlan",title:"VLAN",cellType:"dropdown"},{name:"ipaddress",title:"IP address",cellType:"text"},{name:"mask",title:"Subnet Mask",cellType:"text"},{name:"gateway",title:"Gateway",cellType:"text"}],choices:[{value:"CitrixPres"},{value:"CitrixServer"},{value:"ClinicalServer"},{value:"ClinicalStations"},{value:"Facilities"},{value:"IT_EHR"},{value:"ITAdmin"},{value:"ITServer"},{value:"LoadBalance"},{value:"Management"},{value:"Pacs"},{value:"PharmacyCam_VL"},{value:"Security"},{value:"ServerDMZ"},{value:"TSM_Network"},{value:"VDI"},{value:"vlan1060"},{value:"vlan1688"},{value:"vlan6"},{value:"Vocera"},{value:"xEpicServer"},{value:"YRCC"}],rowCount:1,addRowText:"Add NIC",removeRowText:"Remove NIC"},
{type: "matrixdynamic", name:"drives",title:"Hard Drives",
columns: [{name:"diskletter",title:"Drive Letter",cellType:"dropdown"},{name:"disksize",title:"Disk size in GB",cellType:"text"},{name:"volume",title:"Volume Label",cellType:"text"}],choices:[{value:"C"},{value:"D"},{value:"E"},{value:"F"},{value:"G"},{value:"H"},{value:"I"},{value:"J"},{value:"K"},{value:"L"},{value:"M"},{value:"N"},{value:"O"},{value:"P"},{value:"Q"},{value:"R"},{value:"S"},{value:"T"},{value:"U"},{value:"V"},{value:"W"},{value:"X"},{value:"Y"},{value:"Z"}],rowCount:1,addRowText:"Add Hard Drive",removeRowText:"Remove Hard Drive"}],panelCount:1,minPanelCount:1,panelAddText:"Add Server",panelRemoveText:"Remove Server"}
]}
]}
Please disregard my previous comment. I must have had a typo somewhere in my code. I re-entered the code and have it working now.
Thanks again.
Great!
Thank you,
Andrew
SurveyJS Team