[CLOSED] How to format one grid cell info based on other cell info?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] How to format one grid cell info based on other cell info?

    Hi

    In a grid panel one grid cell value need to format based on other cell info. Please look at the example below.

    I want to add % for grid cell info if other grid cell info value="Y", otherwise the value should be same. I did that from code behind, but while edit row total value with format is showing, which is not right.

    
    <%@ 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">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                LoadStroeInfo();
            }
        }
    
        public void LoadStroeInfo()
        {
            TestStore.DataSource = GetDataInfo();
            TestStore.DataBind();
        }
    
        public DataTable GetDataInfo()
        {
            DataTable dt = new DataTable();
            DataRow dr;
    
            dt.Columns.Add("Test_ID");
            dt.Columns.Add("TestDesc");
            dt.Columns.Add("ReqInfo");
    
            dr = dt.NewRow();
            dr[0] = 1;
            dr[1] = "Test1";
            dr[2] = "Y";
            dt.Rows.Add(dr);
    
            dr = dt.NewRow();
            dr[0] = 2;
            dr[1] = "Test2";
            dr[2] = "N";
            dt.Rows.Add(dr);
    
            dr = dt.NewRow();
            dr[0] = 3;
            dr[1] = "Test3";
            dr[2] = "Y";
            dt.Rows.Add(dr);
    
            dr = dt.NewRow();
            dr[0] = 4;
            dr[1] = "Test4";
            dr[2] = "N";
            dt.Rows.Add(dr);
            
            return dt;
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script language="javascript" type="text/javascript">
            var template1 = '<span >{0}</span>';
            var change = function (value) {            
                return String.format(template1, value + "%");
            };
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="resMngr" runat="server" />
        <ext:Store ID="TestStore" runat="server">
            <Reader>
                <ext:JsonReader IDProperty="Test_ID">
                    <Fields>
                        <ext:RecordField Name="Test_ID" />
                        <ext:RecordField Name="TestDesc" />
                        <ext:RecordField Name="ReqInfo" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Viewport ID="vpProcPage" runat="server" Layout="border">
            <Items>
                <ext:Panel ID="Panel9" runat="server" Layout="Border" Region="Center" Border="false"
                    BodyStyle="background:#ffffff" Margins="5,5,5,5">
                    <Items>
                        <ext:GridPanel ID="gvDocuementReg" runat="server" StoreID="TestStore" AnchorHorizontal="100%"
                            Region="Center" Title="Results" AutoExpandColumn="TestDesc" MaskDisabled="false"
                            StripeRows="true">
                            <Plugins>
                                <ext:RowEditor ID="RowEditor2" runat="server" SaveText="Update" ClicksToEdit="1">
                                    <Listeners>
                                        <%--<AfterEdit Fn="AfterEditRow"></AfterEdit>
                                        <CancelEdit Handler="gvDocuementReg.getSelectionModel().deselectRow(this.grid.getStore().indexOf(this.record));" />--%>
                                    </Listeners>
                                </ext:RowEditor>
                            </Plugins>
                            <ColumnModel ID="ColumnModel3" runat="server">
                                <Columns>
                                    <ext:Column Header="Test Desc" DataIndex="TestDesc">
                                        <Renderer Fn="change" />
                                        <Editor>
                                            <ext:TextField ID="txtTestDesc" runat="server" AllowBlank="false">
                                            </ext:TextField>
                                        </Editor>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:CheckboxSelectionModel ID="CheckboxSelectionModel4" runat="server" />
                            </SelectionModel>
                            <LoadMask ShowMask="true" />
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    </html>
    Last edited by Daniil; Feb 05, 2013 at 3:48 AM. Reason: [CLOSED]
  2. #2
    Hi @rnachman,

    I think you can achieve it setting up a custom Render for the Column.
    http://docs.sencha.com/ext-js/3-4/#!...perty-renderer

    As you can see the record of rendered row is passed as the third argument. So, you can get a value of any record's field.

Similar Threads

  1. [CLOSED] Disabling cell editing based on cell value in Ext.Net 2.1
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 30, 2013, 5:35 PM
  2. [CLOSED] Editable Grid is not showing last changed combobox info
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Dec 11, 2011, 4:41 PM
  3. [CLOSED] How to update all updated grid info in Editable Grid?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 06, 2011, 3:56 PM
  4. [CLOSED] Editable Grid is not showing changed info.
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 06, 2011, 3:40 PM
  5. [CLOSED] Reset store's sort info on grid reload/reconfigure
    By jchau in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Aug 10, 2010, 4:06 PM

Tags for this Thread

Posting Permissions