Boa noite!
Tenho o seguinte cenário: Renderizar o CtreeView com base no value do dropDownList;
tentei da seguinte forma sem sucesso:
registrei a função do jquery.treeview.async logo abaixo da criação dos componentes, a ideia seria de sobrescrever a função para concatenar no parametro data do $.ajax o valor do get:
root: root+’;’+$(’#listname’).val()
echo CHtml::dropDownList('listname', 'A',array('A' => 'Ativos', 'F' => 'Finalizados'));
$this->widget('CTreeView',
array(
'url'=>array('treeFill'),
'animated'=>'normal',
'htmlOptions'=>array('class'=>'treeview-famfamfam')));
Yii::app()->getClientScript()->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript("",";(function($) {
alert('11111');
function load(settings, root, child, container) {
function createNode(parent) {
var current = $('<li/>').attr('id', this.id || '').html('<span>' + this.text + '</span>').appendTo(parent);
if (this.classes) {
current.children('span').addClass(this.classes);
}
if (this.expanded) {
current.addClass('open');
}
if (this.hasChildren || this.children && this.children.length) {
var branch = $('<ul/>').appendTo(current);
if (this.hasChildren) {
current.addClass('hasChildren');
createNode.call({
classes: 'placeholder',
text: ' ',
children:[]
}, branch);
}
if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
}
}
}
$.ajax($.extend(true, {
url: settings.url,
dataType: 'json',
data: {
root: root+';'+$('#listname').val()
},
success: function(response) {
child.empty();
$.each(response, createNode, [child]);
$(container).treeview({add: child});
}
}, settings.ajax));
}var proxied = $.fn.treeview;
$.fn.treeview = function(settings) {
if (!settings.url) {
return proxied.apply(this, arguments);
}
var container = this;
if (!container.children().size())
load(settings, 'source', this, container);
var userToggle = settings.toggle;
return proxied.call(this, $.extend({}, settings, {
collapsed: true,
toggle: function() {
var $"."this = $(this);
if ($"."this.hasClass('hasChildren')) {
var childList = $"."this.removeClass('hasChildren').find('ul');
load(settings, this.id, childList, container);
}
if (userToggle) {
userToggle.apply(this, arguments);
}
}
}));
};
})(jQuery);",CClientScript::POS_LOAD);
Nota: em CClientScript tentei todas as constantes.