[CLOSED] function does not recover the correct values ​​of the states GridPanel

  1. #1

    [CLOSED] function does not recover the correct values ​​of the states GridPanel

    hi,

    I use this method to save whether the column is visible, its width and order.

    The problem is that the values ​​are the old values.
    I explained

    column 1: hidden: false, width: 100, order 1,

    Effective change this column:

    column 1: hiddien: true, width: 100, order 2

    with the method, I state my original column that is not changed.


    Code.aspx
      <ext:GridPanel ID="GridPanelSearch" runat="server" IDMode="Static" StoreID="StoreSearch"
                    TrackMouseOver="false" ForceValidation="true" StripeRows="true" TitleCollapse="true"
                    Collapsible="false" AnimCollapse="true" Icon="Table" ButtonAlign="Right" AutoScroll="true"
                    Border="false" Height="250">
                    <Bin>
                        <ext:MenuItem ID="MenuItem10" runat="server" Text="Save States">
                             <DirectEvents>
                                <Click OnEvent="GetOrder">
                                    <ExtraParams>
                                        <ext:Parameter
                                            Name="order"
                                            Value="getOrder()"
                                            Mode="Raw"
                                            Encode="true" />
                                    </ExtraParams>
                                 </Click>
                            </DirectEvents>
                        </ext:MenuItem>
                    </Bin>
    and we using
    columnModel
    and this to add a column in GridPanel

    <DirectEvents>
                        <Command OnEvent="DisplayInformation">
                            <ExtraParams>
                                <ext:Parameter Name="CotationID" Value="#{GridPanelSearch}.store.getAt(rowIndex).data.CotationID"
                                    Mode="Raw" />

    Method getOrder
     var getOrder = function () {
                var grid = GridPanelSearch,
                    cm = grid.getColumnModel(),
                    order = [];
                var colIndex = 0;
                var hide;
                Ext.each(cm.config, function (c) {
                    if (cm.config[colIndex].hidden == undefined) {
                        hide = false;
                    }
                    else {
                        hide = true;
                    }
                    order.push({
                        header: c.header,
                        hidden: hide,
                        width: c.width
                    });
                    colIndex++;
                });
                return order;
            };
    How to get the current status of the GridPanel? ( i want keep on database not on cookie)

    I may be an option that will not or forget.

    I hope this post is clear enough.
    Last edited by Daniil; Sep 11, 2012 at 1:38 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I tried your function. It seems to work well for my grid, i.e. returns a current order.

    Please provide a full example to run and test.
  3. #3
    Finally now putting on another page, it works fine

    and how to convert this into a function to put it in the C # code?

    Call by ExtraParams

    var getOrder = function () {
               var grid = GridPanelSearch,
                   cm = grid.getColumnModel(),
                   order = [];
               var colIndex = 0;
               var hide;
               Ext.each(cm.config, function (c) {
                   if (cm.config[colIndex].hidden == undefined) {
                       hide = false;
                   }
                   else {
                       hide = true;
                   }
                   order.push({
                       header: c.header,
                       hidden: hide,
                       width: c.width
                   });
                   colIndex++;
               });
               return order;
           };
  4. #4
    It would be better to leave the JavaScript code within <script> tag and populate the ExtraParams this way.

    Example 1
    Ext.Net.Button b = new Ext.Net.Button();
    b.Text = "Save order";
    b.DirectEvents.Click.Event += SaveOrder;
    
    Ext.Net.Parameter p = new Ext.Net.Parameter();
    p.Name = "order";
    p.Value = "getOrder()";
    p.Mode = ParameterMode.Raw;
    p.Encode = true;
                
    b.DirectEvents.Click.ExtraParams.Add(p);
    If it is impossible due to some conditions, then you can do it this way.

    Example 2
    Ext.Net.Parameter p = new Ext.Net.Parameter();
    p.Name = "order";
    p.Value = @"function () {
            /*the getOrder code*/
        }()";
    p.Mode = ParameterMode.Raw;
    p.Encode = true;
                
    b.DirectEvents.Click.ExtraParams.Add(p);
  5. #5
    hi,

    thank you.

    And i solved the first problem

    New code
     var getOrder = function () {
                var grid = GridPanelSearch,
                    cm = grid.getColumnModel(),
                    order = [];
                var colIndex = 0;
                var hide;
                Ext.each(cm.config, function (c) {
                    if (cm.config[colIndex].hidden == undefined || cm.config[colIndex].hidden== false) {   //add cm.config[colIndex].hidden== false, for all case 
                        hide = false;
                    }
                    else {
                        hide = true;
                    }
                    order.push({
                        header: c.header,
                        hidden: hide,
                        width: c.width
                    });
                    colIndex++;
                });
                return order;
            };
    this code : cm.config[colIndex].hidden can have 3 state
    true
    false
    undefined

    Thanks for your help.

    Please, mark as solved.
  6. #6
    Quote Originally Posted by ddslogistics View Post
    this code : cm.config[colIndex].hidden can have 3 state
    true
    false
    undefined
    Good job! I didn't think about it.

Similar Threads

  1. Replies: 1
    Last Post: Jan 19, 2012, 12:11 PM
  2. How to transfer values ​​between different windows?
    By andrefreitasjr in forum 1.x Help
    Replies: 15
    Last Post: Dec 14, 2011, 12:14 PM
  3. [CLOSED] values ​​and columns
    By majunior in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 25, 2011, 9:25 PM
  4. Recover values in selected items GridPanel
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: Jun 22, 2010, 8:19 AM
  5. Save and restore UI states?
    By Zhivko in forum 1.x Help
    Replies: 2
    Last Post: Feb 11, 2010, 10:21 AM

Tags for this Thread

Posting Permissions