Code Monkey home page Code Monkey logo

Comments (12)

mgallegos avatar mgallegos commented on September 2, 2024

Please take a look at issue #31

from laravel-jqgrid.

KrasilnikovKB avatar KrasilnikovKB commented on September 2, 2024

page not found :(
https://github.com/mgallegos/decima-erp/blob/master/workbench/mgallegos/decima-accounting/src/views/account-management.blade.php

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

Sorry, try:

https://github.com/mgallegos/decima-accounting/blob/master/src/views/account-management.blade.php

from laravel-jqgrid.

KrasilnikovKB avatar KrasilnikovKB commented on September 2, 2024

I tried for a long time, but not get the correct result (

if i creating my own implementation of repository class, something like this :

namespace App\Grids;

use Mgallegos\LaravelJqgrid\Repositories\RepositoryInterface;

class ExampleRepository implements RepositoryInterface {

  public function getTotalNumberOfRows(array $filters = array())
  {
      return 5;
  }

 public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
    {

        return array(
            array("id" => 1, "parent_id" => 0, "describe_tree" => "1",   "payloads" => "some helpful information 1"),
            array("id" => 2, "parent_id" => 0, "describe_tree" => "2",   "payloads" => "some helpful information 2"),
            array("id" => 3, "parent_id" => 1, "describe_tree" => "1-1", "payloads" => "some helpful information 3"),
            array("id" => 4, "parent_id" => 2, "describe_tree" => "2-1", "payloads" => "some helpful information 4"),
            array("id" => 5, "parent_id" => 2, "describe_tree" => "2-2", "payloads" => "some helpful information 5"),
        );

    }

 /* 
    !!!!!!!!!!!!!!!!!!!!
 it is necessary to describe here ?
        treeGrid = true;
        parentColumn = 'id';
        eafColumn = 'parent_id';

 how ?
    ????????????????????
*/
}

and creating view some like this:

/* is required to include some external Javascript ? */

GridRender::setGridId("test_tree")

->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')

->setGridOption('treeReader', array('parent_id_field' => 'id', 'leaf_field' => 'parent_id'))

->addColumn(array('index'=>'id',        'name' => 'id',        'hidden' => true ))
->addColumn(array('index'=>'parent_id', 'name' => 'parent_id', 'hidden' => true ) )

->addColumn(array('label'=>'describe_tree','index'=>'describe_tree', 'width' => 150 ) )
->addColumn(array('label'=>'payloads',     'index'=>'payloads',      'width' => 150 ) )

I expect to see something like this:

1       some helpful information 1
 +1-1   some helpful information 3
2       some helpful information 2
 +2-1   some helpful information 4
 +2-2   some helpful information 5

but I get a flat table (((

1       some helpful information 1
2       some helpful information 2
1-1     some helpful information 3
2-1     some helpful information 4
2-2     some helpful information 5

where is error ?

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

ok, first the constructor of your repository class:

public function __construct()
    {
        $this->treeGrid = true;
        $this->parentColumn = 'parent_id';
        $this->leafColumn = 'is_leaf';
    }

And in the getRows function add the leaf column (this is how the grid knows when you can extend the row, 0 to extend, 1 not to extend):

 public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
    {

        return array(
            array("id" => 1, "parent_id" => 0, "describe_tree" => "1",   "payloads" => "some helpful information 1", "is_leaf" => 0),
            array("id" => 2, "parent_id" => 0, "describe_tree" => "2",   "payloads" => "some helpful information 2", "is_leaf" => 0),
            array("id" => 3, "parent_id" => 1, "describe_tree" => "1-1", "payloads" => "some helpful information 3", "is_leaf" => 1),
            array("id" => 4, "parent_id" => 2, "describe_tree" => "2-1", "payloads" => "some helpful information 4", "is_leaf" => 1),
            array("id" => 5, "parent_id" => 2, "describe_tree" => "2-2", "payloads" => "some helpful information 5", "is_leaf" => 1),
        );

    }

Finally in the view, set the tree options correctly:

->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')
->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))

Let me know if it works!

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

And one more thing, try creating and example table in your database, because in this case your repository class will always be returning the same five rows instead of the childs of an specific parent.

from laravel-jqgrid.

KrasilnikovKB avatar KrasilnikovKB commented on September 2, 2024

not workin (
The result :

image

  1. I think that it is generally unnecessary :
public function __construct()
    {
        $this->treeGrid = true;
        $this->parentColumn = 'parent_id';
        $this->leafColumn = 'is_leaf';
    }

because they generally are not declared in the RepositoryInterface. they are only used when json-answer preparing in EloquentRepositoryAbstract

  1. to display properly is really important only what jqGrid-library included on page, and what data is returned to the table from server.

can you show the correct json-response from server, in which is displayed correctly ?

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

The json looks good, are you sure you changed the treeReader property:

->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

You are right, the field level is missing, this is automatically generated by the EloquentRepositoryAbstract class:

 public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
    {

        return array(
            array("id" => 1, "parent_id" => 0, "describe_tree" => "1",   "payloads" => "some helpful information 1", "is_leaf" => 0, "level" => 0 ),
            array("id" => 2, "parent_id" => 0, "describe_tree" => "2",   "payloads" => "some helpful information 2", "is_leaf" => 0, "level" => 0 ),
    }

from laravel-jqgrid.

KrasilnikovKB avatar KrasilnikovKB commented on September 2, 2024

I too found the missing "level"-field at this good example

my final correct data:

->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')
->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))

->addColumn(array('index'=>'id',        'name' => 'id',        'hidden' => true, 'key' => true ))
->addColumn(array('label'=>'describe_tree','index'=>'describe_tree', 'width' => 50 ) )
->addColumn(array('label'=>'payloads',     'index'=>'payloads',      'width' => 50 ) )
return array(
array("level" => 0,  "id" => 1, "parent_id" => "",  "describe_tree" => "1",   "payloads" => "some helpful information 1", "is_leaf" => false),
array("level" => 1,  "id" => 2, "parent_id" => "1", "describe_tree" => "1-1", "payloads" => "some helpful information 3", "is_leaf" => true),
array("level" => 0,  "id" => 3, "parent_id" => "",  "describe_tree" => "2",   "payloads" => "some helpful information 2", "is_leaf" => false),
array("level" => 1,  "id" => 4, "parent_id" => "3", "describe_tree" => "2-1", "payloads" => "some helpful information 4", "is_leaf" => true),
array("level" => 1,  "id" => 5, "parent_id" => "3", "describe_tree" => "2-2", "payloads" => "some helpful information 5", "is_leaf" => true),
        );

in my experience:

  • leaf_field must be boolean (true or false), with 0/1 i got bug :
    image
  • if parent_id recived as string, then grid load as foled:
    image
    , else disclosed :
    image
  • row order is important, I expected that the jqGrid itself will sort them

Thank for help! Now all works fine.

Please, look at my pool requests ;)

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

Nice, I'm glad it worked!

P.D: Yes, I will take a look at them as soon as I can.

from laravel-jqgrid.

mgallegos avatar mgallegos commented on September 2, 2024

And when you do use the EloquentRepositoryAbstract, this code is necessary:

public function __construct()
    {
        $this->treeGrid = true;
        $this->parentColumn = 'parent_id';
        $this->leafColumn = 'is_leaf';
    }

from laravel-jqgrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.