Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add template and method to wrap scripts with a function.#143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
yajra merged 1 commit into4.0fromfunction-template
Oct 9, 2020

Conversation

@yajra
Copy link
Owner

@yajrayajra commentedOct 9, 2020
edited
Loading

This PR will add an option to wrap dataTable scripts within a function.

USAGE / EXAMPLE

DataTable HTML

class EntitiesDataTableHtmlextends DataTableHtml{publicfunctionhandle()    {return$this->setTableId('entities-table')                    ->columns($this->getColumns())                    ->orderBy(count($this->getColumns()) -1)                    ->selectStyleSingle()                    ->responsive(false)                    ->buttons([                        CreateButton::makeIfCan('entities-create')->text('New Entity'),                        EditButton::makeIfCan('entities-update'),                        RemoveButton::makeIfCan('entities-delete')->single(),                        ReloadButton::make(),                    ])                    ->editors([                        Editor::make()                              ->display('large')                              ->fields([Fields\Text::make('category'),Fields\Text::make('name'),                              ]),                    ])// asFunction should be called last to make sure the function template is used.                    ->asFunction();    }/**     * Get columns.     *     * @return array     */protectedfunctiongetColumns()    {return [            CheckboxColumn::make(),            Column::make('category'),            Column::make('name'),        ];    }}

View

<div>    {{$dataTable->table() }}</div>@push('scripts'){{$dataTable->scripts() }}<script src="{{mix('js/entities.js') }}"></script>@endpush

Integration with VueJS

newVue({data:{selected:{},entitiesTable:{}},mounted(){// initialize dataTablethis.entitiesTable=window.dtx['entities-table']();this.entitiesTable.on('select.dt',(e,dt,type,index)=>{this.selected=dt.row(index).data();}).on('deselect.dt',()=>this.selected={})}}).$mount('#entities-app')

@yajrayajra added hacktoberfest hacktoberfest-acceptedAccepted for Hacktoberfest labelsOct 9, 2020
@yajrayajra merged commit43ddf72 into4.0Oct 9, 2020
@yajrayajra deleted the function-template branchOctober 9, 2020 04:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

hacktoberfesthacktoberfest-acceptedAccepted for Hacktoberfest

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@yajra

[8]ページ先頭

©2009-2025 Movatter.jp