toogle in list

Hi,

I have a list that has a template and i want to attach a toggle as a column too…is this posible…

Because i want to do something when toggle value changes…

thanks in advance!!

greetings!

i have this but dont know what i am doing with the activeContent part…

view: “list”,
id: “listUsuarios”,
url: “mocks/usuarios.xml”,
datatype: “xml”,
scroll: true,
css: “transparente”,
type: { height: “auto” },
select: false,
template: function (obj) {
return “

” +
” +
” + obj.nombre + “” +
” + obj.ubicacion + “” +
”;
},
activeContent:
{
Acceptbutton:
{
id: “Acceptbutton”,
view: “toggle”,
labelPosition: “right”,
options: [{ Value: 0, label: “Si” }, { Value: 1, label: “No”}],
width: 80,
value: “#inscrito#”,
//click: upgrade_logic,
on:
{
“onchange”: function (new_value, old_value) {
//setTimeout(“MyTest();”, 100);
alert(“cambiando”);
}
}
}
}
}

Can anyone help me please?

Thanks in advance!!

greetings!

Hello,

you need to apply Acceptbutton in list template. Please see the demo dhtmlxTouch/samples/04_list/11_active_values.html

In case of function definition of template you can do the following:

template: function (obj,common) {
return common.Acceptbutton(obj,common);
}

Thanks,

I have not used the function definition of template yet and it works… so thank you… but i find the function definition of template very interesting…

I have probed it but i have a doubt…

until now… i usually return the html code that i want to use as a template…but you told me to return common.toggleButton(obj, common);

but where i return my html code for the template?

another question…

i want to apply onchange event…

on:
{
“onchange”: function (new_value, old_value) {
//alert(1);
}
}

how do i know the id of the item i am changing in order to do something on the server?

Thanks in advance!!

greetings!

Hello,

I have not used the function definition of template yet and it works…

The template was defined via function in your code snippet that you posted in this topic:

template: function (obj) { return "<div style='width:100%; height:100%; display:block;'>" + ...

So, you can combine the solution that I posted in the previous reply and your code. For example:

template: function (obj,common) { return "<div style='width:100%; height:100%; display:block;'>" +common.Acceptbutton(obj,common)+"...</div>"; },

how do i know the id of the item i am changing

Try the following:

on:{ onchange: function(){ var id = $$("listUsuarios").locate(this.$view); if(id) { ... } } }