<small id='YxNBO'></small><noframes id='YxNBO'>

  • <i id='YxNBO'><tr id='YxNBO'><dt id='YxNBO'><q id='YxNBO'><span id='YxNBO'><b id='YxNBO'><form id='YxNBO'><ins id='YxNBO'></ins><ul id='YxNBO'></ul><sub id='YxNBO'></sub></form><legend id='YxNBO'></legend><bdo id='YxNBO'><pre id='YxNBO'><center id='YxNBO'></center></pre></bdo></b><th id='YxNBO'></th></span></q></dt></tr></i><div id='YxNBO'><tfoot id='YxNBO'></tfoot><dl id='YxNBO'><fieldset id='YxNBO'></fieldset></dl></div>
  • <legend id='YxNBO'><style id='YxNBO'><dir id='YxNBO'><q id='YxNBO'></q></dir></style></legend>

      1. <tfoot id='YxNBO'></tfoot>
          <bdo id='YxNBO'></bdo><ul id='YxNBO'></ul>

        Yii2:使用带分页的 Pjax POST 方法在 Gridview 中搜索

        Yii2 : Search in Gridview using Pjax POST Method with pagination(Yii2:使用带分页的 Pjax POST 方法在 Gridview 中搜索)
          • <bdo id='4vkO9'></bdo><ul id='4vkO9'></ul>

            <tfoot id='4vkO9'></tfoot>

                <tbody id='4vkO9'></tbody>

                <legend id='4vkO9'><style id='4vkO9'><dir id='4vkO9'><q id='4vkO9'></q></dir></style></legend>

                <small id='4vkO9'></small><noframes id='4vkO9'>

                  <i id='4vkO9'><tr id='4vkO9'><dt id='4vkO9'><q id='4vkO9'><span id='4vkO9'><b id='4vkO9'><form id='4vkO9'><ins id='4vkO9'></ins><ul id='4vkO9'></ul><sub id='4vkO9'></sub></form><legend id='4vkO9'></legend><bdo id='4vkO9'><pre id='4vkO9'><center id='4vkO9'></center></pre></bdo></b><th id='4vkO9'></th></span></q></dt></tr></i><div id='4vkO9'><tfoot id='4vkO9'></tfoot><dl id='4vkO9'><fieldset id='4vkO9'></fieldset></dl></div>
                  本文介绍了Yii2:使用带分页的 Pjax POST 方法在 Gridview 中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 yii2 & 的初学者尝试在搜索按钮上使用 Pjax 在 Gridview 中搜索字段.我已使用 GET 方法完成此操作,但我想使用 POST 方法完成此操作.那么我如何使用带有分页的 Yii2 Pjax(post 方法)来做到这一点?

                  这是我的代码:

                  _details.php:

                  registerJs($js);?><div class="col-lg-5"><?phpPjax::begin(['id' => 'bank-form']);$form = ActiveForm::begin(['id' =>'bank-details-form','方法' =>'邮政',]);如果($_REQUEST['bank_name']){$searchModel->bank_name = $selected;}//银行级别 1echo $form->field($searchModel, 'bank_name')->widget(DepDrop::classname(), ['数据' =>$银行名称,'选项' =>['占位符' =>'选择银行'],'类型' =>DepDrop::TYPE_SELECT2,'select2Options' =>['pluginOptions'=>['allowClear'=>true]],'插件选项' =>['取决于' =>[''],'网址' =>Url::to(['/students/child-account']),]]);//状态级别 2echo $form->field($searchModel, 'state')->widget(DepDrop::classname(), ['类型' =>DepDrop::TYPE_SELECT2,'数据' =>$bankState,'选项' =>['占位符'='选择状态'],'select2Options' =>['pluginOptions'=>['allowClear'=>true]],'插件选项' =>['取决于' =>['bankdetails-bank_name'],'网址' =>Url::to(['/students/child-account']),'loadingText' =>'选择银行',]]);//区域级别 3echo $form->field($searchModel, 'district')->widget(DepDrop::classname(), ['数据' =>$bankState,'选项' =>['占位符' =>'选择地区'],'类型' =>DepDrop::TYPE_SELECT2,'select2Options' =>['pluginOptions'=>['allowClear'=>true]],'插件选项' =>['取决于' =>['bankdetails-state'],'网址' =>Url::to(['/students/auto-populate-districts']),'loadingText' =>'选择地区',]]);//城市等级 4echo $form->field($searchModel, 'city')->widget(DepDrop::classname(), ['数据' =>$bankCity,'选项' =>['占位符' =>'选择城市'],'类型' =>DepDrop::TYPE_SELECT2,'select2Options' =>['pluginOptions'=>['allowClear'=>true]],'插件选项' =>['取决于' =>['bankdetails-区'],'网址' =>Url::to(['/students/auto-populate-cities']),'loadingText' =>'选择城市',]]);?><div class="form-group"><br/><?= Html::submitButton('Search', ['class' =>'btn btn-success']) ?>

                  <?php ActiveForm::end();Pjax::end();?>

                  解决方案

                  尝试使用Pjax的post方法:

                  $.pjax.reload({url: url, method: 'POST', container:'#bank-grid'});

                  I am beginner to yii2 & trying to search fields in Gridview using Pjax on search button. I have done this with GET method but I want to do this by using POST method. Then how can I do this with Yii2 Pjax(post method) with pagination?

                  Here is my code :

                  _details.php:

                  <?php          
                  
                      use yiihelpersHtml;                             
                      use yiiwidgetsActiveForm;         
                      use yiiwidgetsPjax;  
                      use kartikdepdropDepDrop; 
                  
                  
                      $js = <<<JS                       
                             // get the form id and set the event                         
                             $('#bank-details-form').on('beforeSubmit', function(e) {           
                             var form = $(this);            
                             if(form.find('.has-error').length) {           
                                  return false;       
                              }   
                  
                              $.ajax({  
                                  url: form.attr('action'),    
                                  type: 'post',   
                                  data: form.serialize(),   
                                  success: function(response) {  
                                      var txtValue = $("#bankdetails-bank_name").val();   
                                      if(txtValue == "")  
                                      {  
                                          alert("Please select bank name");  
                                          return false;  
                                      }   
                  
                                      var bank_name = $('#bankdetails-bank_name option:selected').text();     
                                      var state     = $('#bankdetails-state option:selected').text();     
                                      var district  = $('#bankdetails-district option:selected').text();      
                                      var city      = $('#bankdetails-city option:selected').text();           
                                      var url       = form.attr('action')+ '&BankDetails[bank_name]='+bank_name+'&BankDetails[state]='+state+'&BankDetails[district]='+district+'&BankDetails[city]='+city;         
                  
                                      $.pjax.reload({url: url, container:'#bank-grid'});        
                                  }       
                              });                                          
                          }).on('submit', function(e){                              
                                  e.preventDefault();                         
                          });
                  
                          JS;
                          this->registerJs($js); ?>
                  
                          <div class="col-lg-5">                                            
                  
                          <?php                                  
                  
                              Pjax::begin(['id' => 'bank-form']);                          
                              $form = ActiveForm::begin(['id'  => 'bank-details-form',           
                                                      'method' => 'post',  
                                                      ]);         
                  
                              if($_REQUEST['bank_name'])
                              {
                                  $searchModel->bank_name = $selected;
                              }
                  
                              // Bank level 1
                              echo $form->field($searchModel, 'bank_name')->widget(DepDrop::classname(), [
                              'data'    => $bankName,
                              'options' => ['placeholder' => 'Select Bank'],
                              'type'    => DepDrop::TYPE_SELECT2,
                  
                              'select2Options'  => ['pluginOptions'=>['allowClear'=>true]],
                              'pluginOptions'   => [
                                  'depends'     => [''],
                                  'url'         => Url::to(['/students/child-account']),
                                  ]
                              ]);
                  
                              // State level 2
                              echo $form->field($searchModel, 'state')->widget(DepDrop::classname(), [
                              'type'    => DepDrop::TYPE_SELECT2,
                              'data'    => $bankState,
                              'options' => ['placeholder'=>'Select State'],
                  
                              'select2Options'  => ['pluginOptions'=>['allowClear'=>true]],
                              'pluginOptions'   => [
                                  'depends'     => ['bankdetails-bank_name'],
                                  'url'         => Url::to(['/students/child-account']),
                                  'loadingText' => 'Select Bank',
                              ]
                              ]);
                  
                              // District level 3
                              echo $form->field($searchModel, 'district')->widget(DepDrop::classname(), [
                              'data'    => $bankState,
                              'options' => ['placeholder' => 'Select District'],
                              'type'    => DepDrop::TYPE_SELECT2,
                  
                              'select2Options'  => ['pluginOptions'=>['allowClear'=>true]],
                              'pluginOptions'   => [
                                  'depends'     => ['bankdetails-state'],
                                  'url'         => Url::to(['/students/auto-populate-districts']),
                                  'loadingText' => 'Select District',
                              ]
                              ]);
                  
                              // City level 4
                              echo $form->field($searchModel, 'city')->widget(DepDrop::classname(), [
                              'data'    => $bankCity,
                              'options' => ['placeholder' => 'Select City'],
                              'type'    => DepDrop::TYPE_SELECT2,
                  
                              'select2Options'  => ['pluginOptions'=>['allowClear'=>true]],
                              'pluginOptions'   => [
                                  'depends'     => ['bankdetails-district'],
                                  'url'         => Url::to(['/students/auto-populate-cities']),
                                  'loadingText' => 'Select City',
                              ]
                              ]);
                  
                          ?>
                  
                          <div class="form-group"><br/>
                              <?= Html::submitButton('Search', ['class' => 'btn btn-success']) ?>
                          </div>
                  
                          <?php ActiveForm::end(); 
                               Pjax::end(); ?>
                  
                      </div>
                  

                  解决方案

                  Try using post method of Pjax:

                  $.pjax.reload({url: url, method: 'POST', container:'#bank-grid'}); 
                  

                  这篇关于Yii2:使用带分页的 Pjax POST 方法在 Gridview 中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <i id='oKoS4'><tr id='oKoS4'><dt id='oKoS4'><q id='oKoS4'><span id='oKoS4'><b id='oKoS4'><form id='oKoS4'><ins id='oKoS4'></ins><ul id='oKoS4'></ul><sub id='oKoS4'></sub></form><legend id='oKoS4'></legend><bdo id='oKoS4'><pre id='oKoS4'><center id='oKoS4'></center></pre></bdo></b><th id='oKoS4'></th></span></q></dt></tr></i><div id='oKoS4'><tfoot id='oKoS4'></tfoot><dl id='oKoS4'><fieldset id='oKoS4'></fieldset></dl></div>

                    <small id='oKoS4'></small><noframes id='oKoS4'>

                  1. <tfoot id='oKoS4'></tfoot>

                    • <bdo id='oKoS4'></bdo><ul id='oKoS4'></ul>
                    <legend id='oKoS4'><style id='oKoS4'><dir id='oKoS4'><q id='oKoS4'></q></dir></style></legend>