[0.8.2] Select row from codebehind fire event

  1. #1

    [0.8.2] Select row from codebehind fire event

    Hi,

    I am selecting some rows from codebehind
                foreach (var row in dataTable.Select("ContemBeneficiario = 1"))
                    sm.SelectedRows.Add(new SelectedRow(row[0].ToString()));
    I need it to fire the PrepareToolbar event on the gridpanel. The preparefunction will make the 'Edit' button when a row is selected.

      <ext:CommandColumn Width="110">
        <Commands>
        <ext:GridCommand Hidden="true" Icon="Pencil" CommandName="Editar" Text="Editar" />
        </Commands>
         
     </ext:CommandColumn>
           var prepare = function (grid, toolbar, rowIndex, record) {
                var isSelected = <%= GridPanelBeneficios.ClientID %>.getSelectionModel().isSelected(record);
                
                var firstButton = toolbar.items.get(0);
                if (isSelected) {
                    firstButton.setVisible(true);
                }
                
                //you can return false to cancel toolbar for this record
            }

    THANKS!
  2. #2

    RE: [0.8.2] Select row from codebehind fire event



    I have added a RowSelectionModel to my GridPanel

    rowSelectionModel.Listeners.RowSelect.Handler =
        "#{btnEdit}.enable();#{btnDeleteRow}.enable();#{btnCopyRow}.enable();";
    Buttons are disabled by default

    hth
  3. #3

    RE: [0.8.2] Select row from codebehind fire event

    I will give it a try when i get back to work tomorrow!

    Thanks in advance :D
  4. #4

    RE: [0.8.2] Select row from codebehind fire event

    Thinking it again, i dont think it would work, since i have the edit button inside a gridpanel, i cant access it from the codebehind :(

    Still need ideas, please
  5. #5

    RE: [0.8.2] Select row from codebehind fire event

    Hi

    The text supplied runs on the client

    When the user selects a row the rowselect handler runs clientside (javascript) and enables the buttons

    - Peter
  6. #6

    RE: [0.8.2] Select row from codebehind fire event

    I take back my words, then :)

    I will give it a shot in today at work


  7. #7

    RE: [0.8.2] Select row from codebehind fire event

    THANKS!

    I got it to work.

    This is the solution i used:

     var prepare = function (grid, toolbar, rowIndex, record) {
                // Se já for selecionado da base, seleciona a linha
                if (record.data.CONTEMBENEFICIARIO == 1) {
                    record.data.CONTEMBENEFICIARIO = 0;    
                    <%= GridPanelBeneficios.ClientID %>.getSelectionModel().selectRow(rowIndex);        
                    return true;
                }
    
                var isSelected = <%= GridPanelBeneficios.ClientID %>.getSelectionModel().isSelected(record);
    
                // Se o checkbox estiver marcado e categoria = 2 (veículo), exiba o botão
                if (isSelected &amp;&amp; record.data.RTB_IND_CATEGORIA == 2) {           
                    var firstButton = toolbar.items.get(0);
                    firstButton.setVisible(true);
                   
                    return true;
                }
                
                //you can return false to cancel toolbar for this record
                return false;
            }

Similar Threads

  1. ComboBox TriggerClicked event not fire!
    By rendongsc in forum 1.x Help
    Replies: 2
    Last Post: Mar 30, 2012, 12:29 AM
  2. fire combobox's change event
    By jachnicky in forum 1.x Help
    Replies: 2
    Last Post: Dec 06, 2010, 4:33 PM
  3. How to fire event by row select?
    By mannyk in forum 1.x Help
    Replies: 0
    Last Post: Aug 05, 2010, 9:48 AM
  4. [CLOSED] Is it possible to Select Items of a multi select during ajax event
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 29, 2010, 6:28 PM
  5. CheckColumn fire event
    By fabiomarcos in forum 1.x Help
    Replies: 0
    Last Post: Oct 06, 2009, 10:55 AM

Posting Permissions