5
I have 3 checkbox
(Customer, Supplier and Integrator), each of them when enabled should give access to a tab, I can even make it disable and enable, the problem is that if more than one checkbox
is checked, more than one tab must be accessible to the user.
However with my code that doesn’t happen...
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table class="tbForm">
<tr>
<td colspan="2" class="clMsg"></td>
</tr>
<tr>
<td class="clLegenda">Tipo de Entidade:</td>
</tr>
<tr>
<td class="clLegenda">
<input type="checkbox" id="chkCliente" name="chkCliente" class="toggleTab k-checkbox" data-bind="checked: selecionado.Cliente"/>Cliente
<br/>
<input type="checkbox" id="chkFornecedor" name="chkFornecedor" class="toggleTab k-checkbox" data-bind="checked: selecionado.Fornecedor"/>Fornecedor
<br/>
<input type="checkbox" id="chkIntegrador" name="chkIntegrador" class="toggleTab k-checkbox" data-bind="checked: selecionado.Integrador"/>Integrador
<tr>
<td colspan="4">
<div id="forecast">
<div id="tabstrip" name="tabstrip">
<ul>
<li class="k-state-disabled" id="tabCliente" name="tabCliente">Cliente</li>
<li class="k-state-disabled" id="tabFornecedor" name="tabFornecedor">Fornecedor</li>
<li class="k-state-disabled" id="tabIntegrador" name="tabIntegrador">Integrador</li>
</ul>
<div>
</div>
</td>
</tr>
</table>
<script>
function criaViewModel() {
return new kendo.observable({
registros: dados,
selecionado: new modelo(),
salvar: function () {
$(".clMsg").text("");
if (this.selecionado.Id < 1) {
this.registros.add(this.selecionado);
} else {
if (recuperado) {
var indice = this.registros.indexOf(this.registros.get(this.selecionado.Id));
var registro = this.registros.data()[indice];
for (var _propriedade in modelo.fields) {
registro.set(_propriedade, this.selecionado[_propriedade]);
}
}
}
this.registros.sync();
},
cancelar: function () {
$(".clMsg").text("");
this.registros.cancelChanges();
this.set("selecionado", new modelo());
},
excluir: function () {
if (this.selecionado != null && this.selecionado.Id > 0) {
MsgPergunta(null,"Confirma a exclusão do registro?", Excluir);
}
},
});
}
modelo = kendo.data.Model.define({
id: "Id",
fields: {
Cliente: { editable: true},
Fornecedor: { editable: true},
Integrador: { editable: true},
}
});
dados = criaDataSource(modelo);
$(document).ready(function () {
kendo.culture("pt-BR");
vmObjeto = criaViewModel(); // instancia o vm
vmObjeto.validar = function() { //Valida os campos que estão dentro das tabs
if (vmObjeto.selecionado.Cliente == true){
} else if (vmObjeto.selecionado.Fornecedor == true){
} else if (vmObjeto.selecionado.Integrador == true){
} else{
this.salvar(); //Se os campos obrigatórios estiverem OK manda salvar
}
}
$("#tabstrip").kendoTabStrip({
animation: {
open: {
effects: "fadeIn"
}
}
});
$("#chkCliente").click(function(e) {
if (vmObjeto.selecionado.Cliente == true){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").activateTab("#tabCliente");
}
if (vmObjeto.selecionado.Cliente == false){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").deactivateTab("#tabCliente");
}
});
$("#chkFornecedor").click(function(e) {
if (vmObjeto.selecionado.Fornecedor == true){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").activateTab("#tabFornecedor");
}
if (vmObjeto.selecionado.Fornecedor == false){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").deactivateTab("#tabFornecedor");
}
});
$("#chkIntegrador").click(function(e) {
if (vmObjeto.selecionado.Integrador == true){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").activateTab("#tabIntegrador");
}
if (vmObjeto.selecionado.Integrador == false){
$("#tabstrip").kendoTabStrip().data("kendoTabStrip").deactivateTab("#tabIntegrador");
}
});
</script>
</div>
</body>
</html>
Ex: If chkCliente == true && chkFornecedor == true the Customer and Supplier tabs must be accessible. Not visible, accessible.
– Isa
@Bacco So the user will be able to navigate the tabs and fill in the fields that will be in each of them.
– Isa
Shouldn’t be
enable
anddisable
in place ofactivateTab
anddeactivateTab
then?– Bacco
I tried but it didn’t work.
– Isa
It stays on when I mark and off when I uncheck (exactly as I need), the problem is: If I check the Customer and then uncheck, I still have access to the Customer tab fields.
– Isa
Can you make a simplified version in http://trykendoui.telerik.com/ ? Maybe it will help to correct and test in Altime, and then post it back here.
– Bacco
I will try to do, and as soon as possible post to you @Bacco
– Isa