modify editor fields
modify editor fields
Hi there,
is it possible to somehow change fields depending on what fields I selected before ?
I mean like, you have 2 fields in editor, both are select dropdowns. I know there is ipOpts parameter that allows me to fetch select values from DB, but what if i want to select this fields depending on what i've selected before in field like "town".
[code]var editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "php/table.test.php",
"domTable": "#zoznam",
"fields": [
{
"label": "town",
"name": "town",
"type": "select",
"ipOpts":loader1()
},
{
"label": "street",
"name": "street",
"type": "select",
"ipOpts":loader2()
}
],
} );
[/code]
loader1() will load towns from database and loader2() will load streets from database. I need from loader2 to load only streets what are in town field that was selected before. It will be probably something like :
[code]
{
"label": "street",
"name": "street",
"type": "select",
"ipOpts":loader2(town.selected.value)
}
[/code]
town.selected.value is what i need to give there as parameter. And of course, i need to refresh street field dynamically depending what's actually selected in town field..
is it possible to somehow change fields depending on what fields I selected before ?
I mean like, you have 2 fields in editor, both are select dropdowns. I know there is ipOpts parameter that allows me to fetch select values from DB, but what if i want to select this fields depending on what i've selected before in field like "town".
[code]var editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "php/table.test.php",
"domTable": "#zoznam",
"fields": [
{
"label": "town",
"name": "town",
"type": "select",
"ipOpts":loader1()
},
{
"label": "street",
"name": "street",
"type": "select",
"ipOpts":loader2()
}
],
} );
[/code]
loader1() will load towns from database and loader2() will load streets from database. I need from loader2 to load only streets what are in town field that was selected before. It will be probably something like :
[code]
{
"label": "street",
"name": "street",
"type": "select",
"ipOpts":loader2(town.selected.value)
}
[/code]
town.selected.value is what i need to give there as parameter. And of course, i need to refresh street field dynamically depending what's actually selected in town field..
This discussion has been closed.
Replies
I'll most certainly be looking at making this more flexible for v1.1 and I'll be looking to see what would be involved in allowing options to be dynamically reconfigured in v1.0.1.
Thanks for the feedback on Editor!
Allan
You'd need to bind an event to the element. Something like:
[code]
$(document).on( 'change', '#DTE_Field_first_name', function () {
// value was changed...
} );
[/code]
I think ultimately Editor should provide events that you can listen for when initialising the fields - added to the roadmap. Hope to target 1.1 with that.
Regards,
Allan