PDA

View Full Version : [CLOSED] Add dynamic checkbox in javascript



Tactem
Jan 08, 2013, 1:59 PM
Hi guys,

i wan't add dynamic checkbox in checkboxgroup in js

i test http://forums.ext.net/showthread.php?11794-CLOSED-Add-checkbox-to-checkboxgroup-during-runtime
but this post don't laufen in ext.net 2.1.

control.js


var showAdvancedRight = function (item, record, node, index, e)
{
try {

var listeElement = record.data.ListeUiElement.split(',');
Ext.getCmp('groupTab_LabelTitleAdvanced').setText( record.data.text + ' :');
for (i = 0; i < listeElement.length; i++) {
var group = Ext.getCmp('groupTab_CheckBoxGroupAdvanced');
var cfg = group.initialConfig;
cfg.items.add({
id: 'groupTab_checkbox_' + record.data.text + i,
xtype: "checkbox",
boxLabel: listeElement[i]
});
group.destroy();
new Ext.form.CheckboxGroup(cfg);
}
}
catch (ex) {
App.direct.UnhandledException(' Show advanced rights ' + ex);
}
}

control.ascx


<ext:Panel ID="PanelAdvancedRight" runat="server" Region="East" MinWidth="300" Split="true">
<Items>
<ext:FieldSet ID="GroupAdvancedRights" runat="server" Title="<%$ Resources:UserGroupRightsTab, AdvancedRights %>"
Layout="VBoxLayout" AnchorHorizontal="100%" AnchorVertical="100%" Margin="10">
<Items>
<ext:Label ID="LabelTitleAdvanced" runat="server" />
<ext:CheckboxGroup ID="CheckBoxGroupAdvanced" runat="server" />
</Items>
</ext:FieldSet>
</Items>
</ext:Panel>

Regards

Yoann

Daniil
Jan 08, 2013, 2:41 PM
Hi @Tactem,

The add method appears to function well.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var add = function () {
App.CheckboxGroup1.add({
boxLabel: "dynamic"
});
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:CheckboxGroup ID="CheckboxGroup1" runat="server" ColumnsNumber="1">
<Items>
<ext:Checkbox runat="server" BoxLabel="static" />
</Items>
</ext:CheckboxGroup>

<ext:Button runat="server" Text="add" Handler="add" />
</form>
</body>
</html>

Tactem
Jan 08, 2013, 3:18 PM
Thanks a lot Daniil for your speed response, as always.

Yoann