title: Yii2 get value from Gridview button using javascript
body: <p>I am new to Yii2 Framework , I have developed a module that will upload and display file uploaded from server using Yii2 advance framework. I completed the function for uploading the file , However. In my other function that need to display the file like pdf file to jquery ui dialog.My problem is I cannot get the value of the button when I click the button to display the pdf file uploaded. Thank you guys in advanced.</p>
  
  <pre><code>// Here is Gridview code in Index where my button Exist.
   &lt;?= DynaGrid::widget([
      'columns' =&gt; [
          ['class' =&gt; 'yii\grid\SerialColumn'],
          // 'ntraining_id',
          'ctraining_description',
          //'dtraining_datefrom',
           [
              'attribute'=&gt;'dtraining_datefrom',
              'filterType'=&gt;GridView::FILTER_DATE,
              'format'=&gt;'raw',
              'filterWidgetOptions'=&gt;[
                  'pluginOptions'=&gt;['format'=&gt;'yyyy-mm-dd']
              ],
           ],
         // 'dtraining_dateto',
           [
           'attribute'=&gt;'dtraining_dateto',
           'filterType'=&gt;GridView::FILTER_DATE,
           'format'=&gt;'raw',
           'filterWidgetOptions'=&gt;[
            'pluginOptions'=&gt;['format'=&gt;'yyyy-mm-dd']
           ],
           ],
          'ctraining_numberhours',
          'ctraining_type',
          'ctraining_conducted',
          //'ctraining_attachment',
  
          [
          'attribute'=&gt;'ctraining_attachment',
          'format' =&gt; 'raw',
          'label' =&gt; 'View Profile',
          'value' =&gt; function ($model){
  
                      return  Html::a(Yii::t('app', ' {modelClass}', [
                      'modelClass' =&gt; $model-&gt;ntraining_id,
                      'header' =&gt; 'raw',
  
                      ]), ['TblTrainingController/Listeaffecter'], ['class' =&gt; 'btn btn-success opener', 'id'=&gt;'opener', 'data' =&gt; $model-&gt;ntraining_id,]);   
  
              },
          ],
  
          //'id',
  
          ['class' =&gt; 'yii\grid\ActionColumn'],
          ],
          'storage'=&gt;DynaGrid::TYPE_COOKIE,
          'theme'=&gt;'panel-info',
          'gridOptions'=&gt;[
              'dataProvider' =&gt; $dataProvider,
              'id' =&gt; 'grid',
              'filterModel' =&gt; $searchModel,
              'panel'=&gt;['heading'=&gt;'&lt;h3 class="panel-title"&gt;LEARNING AND DEVELOPMENT (L&amp;D) INTERVENTIONS/TRAINING PROGRAMS ATTENDED&lt;/h3&gt;'],
          ],
      'options'=&gt;['id'=&gt;'dynagrid-1'], // a unique identifier is important
  ]); ?&gt;
  </code></pre>
  
  <p>Here is javascript Code </p>
  
  <pre><code>$this-&gt;registerJs("$(function(){
  
      $('.opener').click(function(e) {
  
              alert(e.data);
             //alert($(this).val());
              e.preventDefault();
              ViewPDfAttach();
  
      });
  </code></pre>
  
  <p>});");</p>
  
  <p><a href="https://i.stack.imgur.com/9U6qK.png" rel="nofollow noreferrer">Here is the image of my interface that display null when I click the button from gridview</a></p>