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

  • <legend id='LMFU3'><style id='LMFU3'><dir id='LMFU3'><q id='LMFU3'></q></dir></style></legend>

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

      1. Yii2 显示每个循环使用的数据

        Yii2 display data using for each loop(Yii2 显示每个循环使用的数据)

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

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

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

                <tfoot id='bY6G1'></tfoot>

                1. 本文介绍了Yii2 显示每个循环使用的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 yii2 我已经使用 gii 创建了一个模型和 CRUD.

                  Using yii2 I have created a Model and CRUD using gii.

                  我想在我的 VIEW 中使用 foreach 或 while 循环以下列格式显示数据

                  I want to use a foreach or while loop in my VIEW to display the data in the following format

                  对于数据库表中的每一行

                  For each row in database table

                  echo("addMarker($lat_field, $lon_field);
                  ");
                  

                  我有一个使用以下控制器操作呈现的索引页.

                  I have an index page which is rendered using the following controller action.

                      public function actionIndex()
                  {
                      $this->layout = 'directory';
                  
                      $searchModel = new ShopDirectorySearch();
                      $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
                  
                      return $this->render('index', [
                          'searchModel' => $searchModel,
                          'dataProvider' => $dataProvider,
                      ]);
                  }
                  

                  我可以使用以下内容使用 listview 显示数据,该列表视图显示数据库中的所有数据/行,但是它周围有 html 并且显然没有以我希望的格式输出.

                  I can use the following to display the data using listview which displays all the data/rows within database however it has html around it and obviously isn't outputted in the format I wish it to be.

                      <?=  ListView::widget([
                   'dataProvider' => $dataProvider,
                   'itemOptions' => ['class' => 'col-xs-6 col-sm-3'],
                   'itemView' => '_index',
                  ]);?>
                  

                  推荐答案

                  这里不需要使用 ListView,你只需尝试:

                  No need to use ListView here, you should simply try :

                  foreach ($dataProvider->models as $model) {
                      echo "addMarker({$model->lat_field}, {$model->lon_field});";
                  }
                  

                  如果你真的想使用 ListView,你可以简单地编辑 _index 视图文件.

                  If you really want to use ListView, you could simply edit _index view file.

                  这篇关于Yii2 显示每个循环使用的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                  How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                  htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                  Joomla include database functions(Joomla 包含数据库功能)
                  nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                  Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)
                2. <i id='eNnWM'><tr id='eNnWM'><dt id='eNnWM'><q id='eNnWM'><span id='eNnWM'><b id='eNnWM'><form id='eNnWM'><ins id='eNnWM'></ins><ul id='eNnWM'></ul><sub id='eNnWM'></sub></form><legend id='eNnWM'></legend><bdo id='eNnWM'><pre id='eNnWM'><center id='eNnWM'></center></pre></bdo></b><th id='eNnWM'></th></span></q></dt></tr></i><div id='eNnWM'><tfoot id='eNnWM'></tfoot><dl id='eNnWM'><fieldset id='eNnWM'></fieldset></dl></div>
                  <legend id='eNnWM'><style id='eNnWM'><dir id='eNnWM'><q id='eNnWM'></q></dir></style></legend>

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

                      <tbody id='eNnWM'></tbody>

                          <tfoot id='eNnWM'></tfoot>
                            <bdo id='eNnWM'></bdo><ul id='eNnWM'></ul>