[FIXED] [#302] [2.x] Add CustomConfig on CheckBox control

Page 1 of 2 12 LastLast
  1. #1

    [FIXED] [#302] [2.x] Add CustomConfig on CheckBox control

    Hi Support team,

    I want to add a customconfig on checkbox control in server code using VB.
    But I can't find this information in this forum.
    I want to setup value either true or false(1 or 0) for initial value. Because I added Change Listeners if I modify initial value it'll occur the event.


    I learned how to init Radio Group from last forum though I don't know it for checkbox.
    Dim setValue As New InsertOrderedDictionary(Of String, Object)
    setValue.Add(rbApprovalAuth.GroupName, "1")
    rbApprovalAuth.CustomConfig.Add(New ConfigItem("value", JSON.Serialize(setValue), ParameterMode.Raw))
    I don't know why this control doesn't have checked event like asp.net.

    Kevin
    Last edited by fabricio.murta; Apr 27, 2016 at 1:07 AM.
  2. #2
    Hi @kevinhwang,

    A CheckboxGroup expects pairs of CheckBoxes' names (equals to its id by default) and true/false.

    So, I think this should work.

    Example
    Dim setValue As New InsertOrderedDictionary(Of String, Object)
    setValue.Add("Checkbox1", True)
    setValue.Add("Checkbox4", True)
    rbApprovalAuth.CustomConfig.Add(New ConfigItem("value", JSON.Serialize(setValue), ParameterMode.Raw))
    I added this thread to this Issue as a duplicate.
    https://github.com/extnet/Ext.NET/issues/290
  3. #3
    Hi Daniil,

    Thanks for your reply but I just use one checkbox control instead CheckBoxGroup and it didn't work with your example.

    <ext:Checkbox ID="chkIsAfterPurchase" runat="server" FieldLabel="Is After Purchase" Hidden="true" LabelWidth="150">
        <Listeners>
            <Change Fn="OnchkIsAfterPurchase_CheckedChanged" />
        </Listeners>
    </ext:Checkbox>
    <DirectMethod([Namespace]:="ContractsCentral.DirectMethods")> _
        Public Sub btnAfterPurDelete_Click()
            Try
                getDicSession()
    
                milestoneCtrl.AfterPurDelete(dicSessionVars("DivAftPurID"))
    
                If milestoneCtrl.bHasExceptions Then
                    Me.Master.SetValidationMessage = milestoneCtrl.sErrorMessage
                Else
                    Dim setValue As New InsertOrderedDictionary(Of String, Object)
                    setValue.Add("chkIsAfterPurchase", False)
                    chkIsAfterPurchase.CustomConfig.Add(New ConfigItem("value", JSON.Serialize(setValue), ParameterMode.Raw))
    
                    FillProcurementHeader()
                End If
    
            Catch ex As Exception
                Me.Master.SetValidationMessage = ex.Message
            Finally
    
            End Try
        End Sub

    Quote Originally Posted by Daniil View Post
    Hi @kevinhwang,

    A CheckboxGroup expects pairs of CheckBoxes' names (equals to its id by default) and true/false.

    So, I think this should work.

    Example
    Dim setValue As New InsertOrderedDictionary(Of String, Object)
    setValue.Add("Checkbox1", True)
    setValue.Add("Checkbox4", True)
    rbApprovalAuth.CustomConfig.Add(New ConfigItem("value", JSON.Serialize(setValue), ParameterMode.Raw))
    I added this thread to this Issue as a duplicate.
    https://github.com/extnet/Ext.NET/issues/290
  4. #4
    Hello!

    You can send true/false to change:

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
        
        <script runat="server">
            public void CheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetValue(true);
            }
            public void UncheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetValue(false);
            }
        </script>
     
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Checkbox ID="chkIsAfterPurchase" runat="server" FieldLabel="Is After Purchase" LabelWidth="150">
                <Listeners>
                    <Change Handler="alert('Changed');"/>
                </Listeners>
            </ext:Checkbox>
            
            <ext:Button runat="server" Text="Check">
                <DirectEvents>
                    <Click OnEvent="CheckClick"></Click>
                </DirectEvents>
            </ext:Button>
            
            <ext:Button runat="server" Text="Uncheck">
                <DirectEvents>
                    <Click OnEvent="UncheckClick"></Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    Hi Baidaly,

    If I don't use CustomConfig option the change event will be occurred on the CheckBox control.
    My case I want to setup the value of the checkbox without any event.

    var OnchkIsAfterPurchase_CheckedChanged = function (checkbox, newValue, oldValue, eOpts) {
                //Ext.Msg.alert("Value", newValue);
                //if (newValue == "true") {
                ContractsCentral.DirectMethods.chkIsAfterPurchase_CheckedChanged(newValue, {
                    eventMask: { showMask: true }
                });
                //}
            }
    var OnbtnAfterPurDelete_Click = function () {
                ContractsCentral.DirectMethods.btnAfterPurDelete_Click({
                    eventMask: { showMask: true }
                });
            };
    
    <ext:Checkbox ID="chkIsAfterPurchase" runat="server" FieldLabel="Is After Purchase" Hidden="true" LabelWidth="150">
                                    <Listeners>
                                        <Change Fn="OnchkIsAfterPurchase_CheckedChanged" />
                                    </Listeners>
                                </ext:Checkbox>
    
    <ext:Button ID="btnAfterPurDelete" runat="server" Text="Delete">
                                            <Listeners>
                                                <Click Fn="OnbtnAfterPurDelete_Click" />
                                            </Listeners>
                                        </ext:Button>
    <DirectMethod([Namespace]:="ContractsCentral.DirectMethods")> _
        Public Sub chkIsAfterPurchase_CheckedChanged(ByVal strBool As String)
            Dim blChk As Boolean = Convert.ToBoolean(strBool)
    
            If blChk Then
                getDicSession()
    
                milestoneCtrl.changeAfterPurchase(dicSessionVars("divid"), intProcureID, dicSessionVars("ReqID"), GetFromSession("_strUserId"))
    
                If milestoneCtrl.bHasExceptions Then
                    Me.Master.SetValidationMessage = milestoneCtrl.sErrorMessage
                Else
                    FillProcurementHeader()
                End If
    
                If milestoneCtrl.bHasExceptions Then
                    Me.Master.SetValidationMessage = milestoneCtrl.sErrorMessage
                End If
            End If
    
        End Sub
    <DirectMethod([Namespace]:="ContractsCentral.DirectMethods")> _
        Public Sub btnAfterPurDelete_Click()
            Try
                getDicSession()
    
                milestoneCtrl.AfterPurDelete(dicSessionVars("DivAftPurID"))
    
                If milestoneCtrl.bHasExceptions Then
                    Me.Master.SetValidationMessage = milestoneCtrl.sErrorMessage
                Else
                    'Dim setValue As New InsertOrderedDictionary(Of String, Object)
                    'setValue.Add("chkIsAfterPurchase", False)
                    'chkIsAfterPurchase.CustomConfig.Add(New ConfigItem("value", JSON.Serialize(setValue), ParameterMode.Raw))
                    chkIsAfterPurchase.SetValue(False)
                    FillProcurementHeader()
                End If
    
            Catch ex As Exception
                Me.Master.SetValidationMessage = ex.Message
            Finally
    
            End Try
        End Sub
    Quote Originally Posted by Baidaly View Post
    Hello!

    You can send true/false to change:

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
        
        <script runat="server">
            public void CheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetValue(true);
            }
            public void UncheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetValue(false);
            }
        </script>
     
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Checkbox ID="chkIsAfterPurchase" runat="server" FieldLabel="Is After Purchase" LabelWidth="150">
                <Listeners>
                    <Change Handler="alert('Changed');"/>
                </Listeners>
            </ext:Checkbox>
            
            <ext:Button runat="server" Text="Check">
                <DirectEvents>
                    <Click OnEvent="CheckClick"></Click>
                </DirectEvents>
            </ext:Button>
            
            <ext:Button runat="server" Text="Uncheck">
                <DirectEvents>
                    <Click OnEvent="UncheckClick"></Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  6. #6
    What about to use a Checkbox's Checked property?
  7. #7
    It still has same issue.
    I used Checked Property to setup the checkbox unchecked but it still occur the same event, Change.
    But I put some code to check whether it's checked before run so I'll use this way until I know how to use CustomConfig setting for the checkbox control.


    Kevin

    Quote Originally Posted by Daniil View Post
    What about to use a Checkbox's Checked property?
  8. #8
    If don't need event fire you should use SetRawValue:

    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
         
        <script runat="server">
            public void CheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetRawValue(true);
            }
            public void UncheckClick(object server, DirectEventArgs e)
            {
                chkIsAfterPurchase.SetRawValue(false);
            }
        </script>
      
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
             
            <ext:Checkbox ID="chkIsAfterPurchase" runat="server" FieldLabel="Is After Purchase" LabelWidth="150">
                <Listeners>
                    <Change Handler="alert('Changed');"/>
                </Listeners>
            </ext:Checkbox>
             
            <ext:Button runat="server" Text="Check">
                <DirectEvents>
                    <Click OnEvent="CheckClick"></Click>
                </DirectEvents>
            </ext:Button>
             
            <ext:Button runat="server" Text="Uncheck">
                <DirectEvents>
                    <Click OnEvent="UncheckClick"></Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  9. #9
    Another option is suspending events.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void CheckClick(object server, DirectEventArgs e)
        {
            this.Checkbox1.SuspendEvents();
            this.Checkbox1.Checked = true;
            this.Checkbox1.ResumeEvents();
        }
        public void UncheckClick(object server, DirectEventArgs e)
        {
            this.Checkbox1.SuspendEvents();
            this.Checkbox1.Checked = false;
            this.Checkbox1.ResumeEvents();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Checkbox ID="Checkbox1" runat="server" FieldLabel="Checkbox">
                <Listeners>
                    <Change Handler="alert('Changed');" />
                </Listeners>
            </ext:Checkbox>
    
            <ext:Button runat="server" Text="Check" OnDirectClick="CheckClick" />
    
            <ext:Button runat="server" Text="Uncheck" OnDirectClick="UncheckClick" />
        </form>
    </body>
    </html>
  10. #10
    Thanks Daniil and Baidaly

    I decided to use SuspendEvents and ResumeEvents function.
    I don't know why the first click event on the control didn't occur after I used the SetRawValue function for the check box.

    Kevin

    SuspendEvents()
    SetValue(False)
    ResumeEvents()
    Quote Originally Posted by Daniil View Post
    Another option is suspending events.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void CheckClick(object server, DirectEventArgs e)
        {
            this.Checkbox1.SuspendEvents();
            this.Checkbox1.Checked = true;
            this.Checkbox1.ResumeEvents();
        }
        public void UncheckClick(object server, DirectEventArgs e)
        {
            this.Checkbox1.SuspendEvents();
            this.Checkbox1.Checked = false;
            this.Checkbox1.ResumeEvents();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Checkbox ID="Checkbox1" runat="server" FieldLabel="Checkbox">
                <Listeners>
                    <Change Handler="alert('Changed');" />
                </Listeners>
            </ext:Checkbox>
    
            <ext:Button runat="server" Text="Check" OnDirectClick="CheckClick" />
    
            <ext:Button runat="server" Text="Uncheck" OnDirectClick="UncheckClick" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Jul 15, 2013 at 3:38 AM. Reason: Please use [CODE] tags
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jan 30, 2014, 5:38 AM
  2. Replies: 2
    Last Post: Oct 08, 2012, 4:56 PM
  3. Replies: 3
    Last Post: Jun 02, 2011, 8:45 PM
  4. [FIXED] [0.8.2] CheckBox missing?
    By Timothy in forum Bugs
    Replies: 4
    Last Post: Oct 09, 2009, 10:21 AM
  5. [FIXED] [V0.6] CheckBox and Radio
    By Timothy in forum Bugs
    Replies: 2
    Last Post: Sep 16, 2008, 10:50 AM

Posting Permissions