Coder Social home page Coder Social logo

ColumnConfiguration about datatable HOT 7 CLOSED

openskill avatar openskill commented on July 21, 2024
ColumnConfiguration

from datatable.

Comments (7)

Chumper avatar Chumper commented on July 21, 2024

The ColumnConfiguration has these properties at the moment:

  • $name internal name for the confiiguration
  • $searchable if the column should be searchable
  • $orderabe if the column should be orderable
  • $callable the function to call when the column should be evaluated

The method signature looks like this

What additional Features does the DTDataComposer need?

from datatable.

Javier-Rotelli avatar Javier-Rotelli commented on July 21, 2024

it would be nice to have a way to pass config options to the columns array. at least the most common options

from datatable.

Chumper avatar Chumper commented on July 21, 2024

What do you mena exactly with config options?
Can you show some code?

from datatable.

Javier-Rotelli avatar Javier-Rotelli commented on July 21, 2024

let me show:
this is what i do now:

Datatable::table()->addColumn('One','Two','Three')
                        (...)
                        ->setOptions([
                                      'aoColumns'=>[
                                          null,
                                          ['sWidth'=>'50%'],
                                          ['sWidth'=>'40%','sClass'=>'text-right']
                                      ]]);

this generates:

"aoColumns":[ 
    null,
    { "sWidth":"50%" },
    { "sWidth":"40%", "sClass":"text-right" } 
]

there are a number of options to customize the columns. it would be nice to be able to put those options when you define the column.

a posibility is:

public function column($name, callable $callable = null, $searchable = true, $orderable = true, $options = [])

from datatable.

Chumper avatar Chumper commented on July 21, 2024

Yes, I had that in mind, however, i would like to put the reponsibility into the view part of the configuration.
So a more sophisticated example could look like this:

// Generate server side configuration
$table = Datatable::make(new CollectionProvider(User::all()))
    ->column('id') // defaults to sortable and searchable
    ->column('name', function($data) { return $data->extraLongPropertyName; })
    ->build(); // will generate the table which now can be used to handle requests or be passed to the view.

// server side
if(Datatable::shouldHandle()) {
    $table->handleRequest();
}

// client side (e.g. in view)
$table->view(Version::Datatable_1_9)
    ->addOption('name', ... your options)
    ->render() 

Would that also work? I would like to clearly separate the server side from the client side.

from datatable.

Javier-Rotelli avatar Javier-Rotelli commented on July 21, 2024

I like that.
the problem i had with the old version was the need to put the whole "aoColumns" and having to put the options in order. which is a little annoying.

from datatable.

Chumper avatar Chumper commented on July 21, 2024

Column configuration was implemented, look over it and let me know what you think

from datatable.

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.