[CLOSED] How to get the pressed value of a GridCommand ?

  1. #1

    [CLOSED] How to get the pressed value of a GridCommand ?

    Hello,

    I have a Grid that offers a refresh button in each row. The grid also has two gridCommands with toggle functionality.

    My refresh function needs to know if these gridCommands are pressed or not.

    My GridCommands:

    
                                            <ext:CommandColumn ID="CommandColumn2" runat="server" Width="30">
                                                <Commands>
                                                    <ext:GridCommand Icon="ArrowSwitch" CommandName="linieAnzeigen" StandOut="false">
                                                        <ToolTip Text="Linie anzeigen" />
                                                        <CustomConfig>
                                                            <ext:ConfigItem Name="enableToggle" Value="true" />
                                                            <ext:ConfigItem Name="pressed" Value="true" />
                                                        </CustomConfig>
                                                    </ext:GridCommand>
                                                </Commands>
                                                <Listeners>
                                                    <Command Handler="showTourbyID(record.data.TourNummer,command);" />
                                                </Listeners>
                                            </ext:CommandColumn>
                                            <ext:CommandColumn ID="CommandColumn3" runat="server" Width="30">
                                                <Commands>
                                                    <ext:GridCommand Icon="BulletGreen" CommandName="punkteAnzeigen" StandOut="false">
                                                        <ToolTip Text="Punkte anzeigen" />
                                                        <CustomConfig>
                                                            <ext:ConfigItem Name="enableToggle" Value="true" Mode="Raw" />
                                                        </CustomConfig>
                                                    </ext:GridCommand>
                                                </Commands>
                                                <PrepareToolbar Fn="prepareTogglePoints" />
                                                <Listeners>
                                                    <Command Handler="showTourbyID(record.data.TourNummer,command);" />
                                                </Listeners>
                                            </ext:CommandColumn>
    My refresh function is client side, how can I access the pressed value(or toggle-status) of these two grid commands?
    Last edited by Daniil; Jan 11, 2013 at 3:44 AM. Reason: [CLOSED]
  2. #2
    Hi @blueworld,

    I would try to keep pressed state of the commands in a Store's record.
  3. #3
    Hi Daniil,

    so there is now way to access the pressed property directly?
    Putting them into the store might be a solution, but then I have to manage these values with every toggle.
  4. #4
    You could access it this way:
    App.CommandColumn1.cache[0].items.get(0);
    But, I am afraid, you won't avoid using records. Because commands are re-rendered on each GridPanel refresh. For example, after any data changing: loading, sorting, filtering.

    For example, if you toggle the command, then sort the data in the GridPanel, the commands will be re-rendered and the toggled state will be lost.

    To avoid it, the state should be saved in a record and restored in the PrepareToolbar handler.

    It was discussed here.
    http://forums.ext.net/showthread.php?20770
  5. #5
    Hi Daniil,

    so far your suggestion works fine except that the click event does not get triggered that way.

            var prepareTogglePoints = function(grid, toolbar, rowIndex, record) {
                var command = toolbar.items.get(0);
                command.toggle(record.get("PunktePressed"));
            };
                                            <ext:CommandColumn ID="CommandColumn3" runat="server" Width="30">
                                                <Commands>
                                                    <ext:GridCommand Icon="BulletGreen" CommandName="punkteAnzeigen" StandOut="false">
                                                        <ToolTip Text="Punkte anzeigen" />
                                                        <CustomConfig>
                                                            <ext:ConfigItem Name="enableToggle" Value="true" Mode="Raw" />
                                                        </CustomConfig>
                                                    </ext:GridCommand>
                                                </Commands>
                                                <PrepareToolbar Fn="prepareTogglePoints" />
                                                <Listeners>
                                                    <Command Handler="showTourbyID(record.data.TourNummer,command);" />
                                                </Listeners>
                                            </ext:CommandColumn>
    I guess its because the toolbar now just gets rendered as pressed, without having the listener active at this moment right?
    Last edited by blueworld; Jan 07, 2013 at 4:20 PM.
  6. #6
    Seems I don't see the Click listener in your code sample. Do you mean the Command listener?

    Could you, please, provide a full sample to test with?
  7. #7
    Hi Daniil,

    thank you but this problem is already solved.

    But I still have a problem:

    App.CommandColumn1.cache[0].items.get(0);
    does not return correct values if there is more than one record in my grid. If my new record is NOT pressed, this function delivers true, i guess because a previous row contains a pressed commandButton
    Is there any other way to access the pressed value of my commandColumn?

    Sometimes it delivers true even if ALL CommandColumns are unpressed, is there any way to force the cache to refresh ?
    Last edited by blueworld; Jan 08, 2013 at 10:07 AM.
  8. #8
    Try to find a toolbar by record's id.

    for (var i = 0, l = column.cache.length; i < l; i++) {
        if (column.cache[i].record && (column.cache[i].record.id == record.id)) {
            var toolbar = column.cache[i];
        }
    }

Similar Threads

  1. Focus first field in form when TAB is pressed
    By chezinho in forum 1.x Help
    Replies: 2
    Last Post: Dec 08, 2010, 9:02 PM
  2. [1.0] how to catch keys pressed on codebehind
    By marcelodecon in forum 1.x Help
    Replies: 1
    Last Post: Aug 11, 2010, 9:45 PM
  3. [CLOSED] [1.0] Issue detecting pressed button state
    By edigital in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 29, 2010, 4:21 PM
  4. Replies: 2
    Last Post: Feb 01, 2010, 1:00 PM
  5. Replies: 3
    Last Post: Mar 10, 2009, 11:56 AM

Tags for this Thread

Posting Permissions