[CLOSED] Field Converter to button

  1. #1

    [CLOSED] Field Converter to button

    Based on the example provided here https://examples2.ext.net/#/GridPane...eld_Converter/

    I need to use the same idea but convert all fields except the FundName to buttons with action on server side button click. data will be coming from a store with flags of true or false instead of "y" or "no".

    The screenshot attached is the same functionnality I am trying to accomplish but using the Grid Panel. In the screenshot i am using the classic ASP.NET Grid View
    <ext:GridPanel ID="GridPanel1" runat="server"  Width="600" Height="350">
                                <Store>
                                    <ext:Store ID="Store2" runat="server">
                                        <Model>
                                            <ext:Model ID="Model2" runat="server" IDProperty="company">
                                                <Fields>
                                                    <ext:ModelField Name="FundName" />
                                                    <ext:ModelField Name="CreateLetter" Type="string" />
                                                    <ext:ModelField Name="Approved" Type="string" />
                                                    <ext:ModelField Name="SendNow" Type="string" />
                                                    <ext:ModelField Name="Override" Type="string">
                                                        <Convert Handler="return value === 1;" />
                                                    </ext:ModelField>
                                                </Fields>
                                            </ext:Model>
                                        </Model>
                                    </ext:Store>
                                </Store>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column ID="Column1" runat="server" Text="Fund Name" Width="160" DataIndex="FundName"
                                            Flex="1" />
                                        <ext:Column ID="Column2" runat="server" Text="Create Letter" Width="75" DataIndex="CreateLetter" />
                                        <ext:Column ID="Column3" runat="server" Text="Approved" Width="75" DataIndex="Approved" />
                                        <ext:Column ID="Column4" runat="server" Text="Sendnow" Width="75" DataIndex="pctChange" />
                                        <ext:CheckColumn ID="CheckColumn1" runat="server" Text="Override" Width="50" Sortable="true" DataIndex="Override" />
                                    </Columns>
                                </ColumnModel>
                            </ext:GridPanel>
    protected void Page_Load(object sender, EventArgs e)
            {
    
                if (!X.IsAjaxRequest)
                {
                    this.BindData();
                }
    
    
            }
    
            protected void MyData_Refresh(object sender, StoreReadDataEventArgs e)
            {
                this.BindData();
            }
            private void BindData()
            {
                var store = this.GridPanel1.GetStore();
    
                store.DataSource = this.Data;
                store.DataBind();
            }
    
            private object[] Data
            {
                get
                {
                    DateTime now = DateTime.Now;
    
                    return new object[]
                    {
               
                        
                        new object[] { "3m Co", 1, 1, 1, 1 },
                        new object[] { "Alcoa Inc", 1, 0, 0, 1 },
                        new object[] { "Altria Group Inc", 0, 1, 1.1, 0 },
                        new object[] { "Wal-Mart Stores, Inc.", 0, 0, 1, 0 }
    
    
                        
                    };
                }
    Please help!!!
    Attached Thumbnails Click image for larger version. 

Name:	Commad on demand.jpg 
Views:	41 
Size:	62.9 KB 
ID:	5094  
    Last edited by Daniil; Nov 16, 2012 at 5:42 PM. Reason: [CLOSED]
  2. #2
    I recommend you to use RowCommand Click image for larger version. 

Name:	RowCommands.PNG 
Views:	47 
Size:	11.0 KB 
ID:	5097.

    You look examples there https://examples2.ext.net/#/GridPane...s/Row_Command/ and https://examples2.ext.net/#/GridPane...pare_Commands/.

    Also, I modified your example to show you:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BindData();
            }
        }
     
        protected void MyData_Refresh(object sender, StoreReadDataEventArgs e)
        {
            this.BindData();
        }
        
        private void BindData()
        {
            var store = this.GridPanel1.GetStore();
     
            store.DataSource = this.Data;
            store.DataBind();
        }
    
    	private object[] Data
     {
     	get
     	{
     		return new object[]
     		       	{
    
    
     		       		new object[] {"3m Co", 1, 1, 1, 1},
     		       		new object[] {"Alcoa Inc", 1, 0, 0, 1},
     		       		new object[] {"Altria Group Inc", 0, 1, 1.1, 0},
     		       		new object[] {"Wal-Mart Stores, Inc.", 0, 0, 1, 0}
     		       	};
     	}
     }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <script>
            var prepareCreateLetterToolbar = function (grid, toolbar, rowIndex, record) {
                if (record.get('CreateLetter') == '1')
                    toolbar.items.getAt(0).hide();
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel ID="GridPanel1" runat="server"  Width="600" Height="350">
                <Store>
                    <ext:Store ID="Store2" runat="server">
                        <Model>
                            <ext:Model ID="Model2" runat="server" IDProperty="company">
                                <Fields>
                                    <ext:ModelField Name="FundName" />
                                    <ext:ModelField Name="CreateLetter" Type="string" />
                                    <ext:ModelField Name="Approved" Type="string" />
                                    <ext:ModelField Name="SendNow" Type="string" />
                                    <ext:ModelField Name="Override" Type="string">
                                        <Convert Handler="return value === 1;" />
                                    </ext:ModelField>
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Fund Name" Width="160" DataIndex="FundName"
                            Flex="1" />
                        <ext:CommandColumn ID="Column2" runat="server" Text="Create Letter" Width="100" DataIndex="CreateLetter">
                            <Commands>
                                <ext:GridCommand Icon="Email" CommandName="createLetter" Text="Create Letter">
                                    <ToolTip Text="Delete" />
                                </ext:GridCommand>
                            </Commands>
                            <PrepareToolbar Fn="prepareCreateLetterToolbar" />
                            <Listeners>
                                <Command Handler="Ext.Msg.alert('Clicked');" />
                            </Listeners>
                        </ext:CommandColumn>
                        <ext:Column ID="Column3" runat="server" Text="Approved" Width="75" DataIndex="Approved" />
                        <ext:Column ID="Column4" runat="server" Text="Sendnow" Width="75" DataIndex="pctChange" />
                        <ext:CheckColumn ID="CheckColumn1" runat="server" Text="Override" Width="50" Sortable="true" DataIndex="Override" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3

    works

    Thank you this works great, i will combine your solution with other finding from forums replies. you may close this ticket.

Similar Threads

  1. Field Converter to button
    By otouri in forum 2.x Help
    Replies: 10
    Last Post: Nov 16, 2012, 4:20 PM
  2. [CLOSED] Problem with Converter on Date RecordField
    By GLD in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 31, 2012, 2:44 PM
  3. [CLOSED] [1.0] Field with Label margin-button
    By kemalyigit in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 11, 2010, 4:18 AM
  4. [CLOSED] Disable browse button of fileupload field
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 26, 2009, 11:44 AM
  5. Replies: 1
    Last Post: Jul 20, 2009, 7:44 AM

Posting Permissions