[CLOSED] Reading grid in the server

  1. #1

    [CLOSED] Reading grid in the server

    To read grids values posted back to the server, we do the following:

    Put this javascript in the event that will cause the postback, i.e. button click:

    <ext:Button ID="btExcluir" runat="server" SkinID="btExcluirSkin">
                            <DirectEvents>
                                <Click>
                                    <ExtraParams>
                                        <ext:Parameter Name="Perfis" Value="Ext.encode(#{gvPerfis}.getRowsValues({selectedOnly:false}))"
                                            Mode="Raw" />
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
    And in the server we do this to get the value:

    string jsonPerfis = e.ExtraParams["Perfis"];
    PerfilAcesso[] rowsPerfis = JSON.Deserialize<PerfilAcesso[]>(jsonPerfis);
    Is there an easier approach to get the values from a store in the server without using javascrpit in each event and JSON?
    Isn't there a way to read the store or the grid data directly, the same way i can read a TextField?
    Last edited by Daniil; Jul 16, 2012 at 9:46 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The Store/GridPanel data is not sent to server automatically. Here are the details.
    http://forums.ext.net/showthread.php...ll=1#post43229

    So, you should do it manually as you do.

    Though you could improve that in two ways.

    1. Set up a default extra parameter for each DirectEvent/DirectMethod. Like this:
    http://forums.ext.net/showthread.php...ll=1#post78639

    2. Listen the Store Load and/or DataChanged events to set up the value for some Hidden field, then read its value on server.

    Personally, I would prefer to send the Store/GridPanels data to server for the events only which require this data.
  3. #3
    Hi Daniil,

    Understood, it would really be expensive to send the store to the server on every postback, but please consider creating a way to ease the process in a way that the developer wouldn't have to manually attach the javascript in the parameter every time, deserialize the value, etc.

    I created these methods in our framework to ease the process:

        private static String GetGridSubmitParamName(Store store)
            {
                return String.Format("__SUBMITPARAM_{0}", store.ID);
            }
    
           public static void ConfigureButtonForStoreDataSubmit(ComponentDirectEvent directEvent, Store storeToBeSubmitted)
            {
                directEvent.ExtraParams.Add(
                                new Parameter()
                                {
                                    Mode = ParameterMode.Raw,
                                    Name = GetGridSubmitParamName(storeToBeSubmitted),
                                    Value = String.Format("Ext.encode(#{{{0}}}.getRecordsValues())", storeToBeSubmitted.ID)
                                });
            }
    
            public static void LoadStoreValue<T>(Store store, DirectEventArgs e)
            {
                String parameterValue = e.ExtraParams[GetGridSubmitParamName(store)];
                store.DataSource = Ext.Net.JSON.Deserialize<T>(parameterValue);
            }
  4. #4
    Please clarify do you have any concrete suggestions? We would be happy to build in the toolkit.

    Generally, the process doesn't look difficult since a developer just needs to call the getRowsValues or getRecordsValues methods (one code line) and deserialize it on server by calling the JSON.Deserialize method (also, one code line).

Similar Threads

  1. [CLOSED] Reading controls int tabpanels issue
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 13, 2011, 2:17 PM
  2. Reading checkbox value from tabpage
    By prost in forum 1.x Help
    Replies: 10
    Last Post: May 17, 2011, 7:39 AM
  3. [CLOSED] Problems reading slider value in javascript
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 07, 2011, 10:33 AM
  4. [CLOSED] Reading SelectedRow Column values
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 09, 2010, 10:51 AM
  5. [CLOSED] Reading data from a store in codebehind
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 16, 2009, 5:11 PM

Posting Permissions