dougan1330 2019-03-07 06:54
浏览 85

laravel-jqgrid处理原始查询

I am using a laravel-jqgrid library of "mgallegos/laravel-jqgrid". When using query builder it works fine, but my requirement is to use raw queries. How can I handle that?

Here are my codes:

GridRepository.php:

namespace Repositories;

use \Illuminate\Support\Facades\DB;
use App\App;
use Mgallegos\LaravelJqgrid\Repositories\EloquentRepositoryAbstract;

class GridRepository extends EloquentRepositoryAbstract {

    public function __construct($db_obj, $columns, $order_by)
    {
        $this->Database = $db_obj;

        $this->visibleColumns = $columns;

        $this->orderBy = $order_by;
    }

}

GridController:

class JqGridController extends Controller {

  protected $GridEncoder;

  public function __construct(RequestedDataInterface $GridEncoder)
  {
      $this->GridEncoder = $GridEncoder;
  }

  public function getIndex()
  {
      return View::make('grid-apps');
  }

  public function postGridData()
  {
      $db_obj = DB::table('applications')
               ->join('branches', 'applications.branchid', '=', 'branches.id')
               ->whereNotIn('applications.status', ['Reject', 'Rejected', 'Deleted']);

      $columns = array('applications.status','branches.name as branches.name', 'applications.created_at as applications.created_at', 'applications.amount');

      $order_by = array(array('applications.created_at', 'asc'));

      $this->GridEncoder->encodeRequestedData(new GridRepository($db_obj, $columns, $order_by), Input::all());
  }

}

In search option of jqgrid I have added following code:

searching: {
            closeAfterSearch: true,
            closeAfterReset: true,
            closeOnEscape: true,
            searchOnEnter: true,
            multipleSearch: true,
            multipleGroup: true,
            showQuery: true,
            afterShowSearch: function(event){
                console.log('event', event);
                $(document).find('.add-group').hide();
            }
}

How can I achieve that using a raw query? Because we were using Ajax datatable on raw query there are 100s of tables made from datatables. Now we are moving to jqgrid, so we want less changes to move.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 聚类分析或者python进行数据分析
    • ¥15 如何用visual studio code实现html页面
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?