GithubHelp home page GithubHelp logo

lombiq / orchard-data-tables Goto Github PK

View Code? Open in Web Editor NEW
3.0 8.0 1.0 1.75 MB

License: BSD 3-Clause "New" or "Revised" License

C# 67.88% JavaScript 20.48% HTML 8.31% CSS 3.33%
orchard orchard-cms orchard-module datatables orchard-core

orchard-data-tables's Introduction

Lombiq Data Tables for Orchard Core

Lombiq.DataTables NuGet Lombiq.DataTables.Samples NuGet Lombiq.DataTables.Tests.UI NuGet

About

An Orchard Core wrapper around the DataTables library for displaying tabular data from custom data sources.

Note that this module has an Orchard 1 version in the dev-orchard-1 branch.

Do you want to quickly try out this project and see it in action? Check it out in our Open-Source Orchard Core Extensions full Orchard Core solution and also see our other useful Orchard Core-related open-source projects!

How to use

You can find a sample module with a commented walkthrough in this repository. Check it out here!

Static Content With Tag Helper

In the most basic form you can use DOM sourced data with the <datatable> tag helper.

Asynchronous Content With a Custom Provider

The Lombiq_DataTable shape can display sortable, searchable, paginated data, but you must make your own data provider by extending DataTableDataProviderBase or either of the abstract base classes provided by us (JsonResultDataTableDataProvider, IndexBasedDataTableDataProvider). The latter is for complex database queries that would take a long time to calculate on demand, are tied to one or more content items and can be indexed ahead of time.

Once you have your data provider, it must be registered using services.AddDataTableDataProvider<TProvider>(), or if it's index-based then using services.AddIndexBasedDataTableProvider<TIndex, TGenerator, TMigration, TProvider>().

If you need an admin page with just one data table you don't need to define a view, just link to /Admin/DataTable/{providerName}/{queryId?}.

You can find an example using LinqToDb queries do display a table of deleted content items at DeletedContentItemDataTableDataProvider.cs.

If you want a display a table of deleted content items, we already happen to have a provider for that called DeletedContentItemDataTableDataProvider.

Client-side Extensibility

With Shape

For configuring the setup logic or global customization you can override the Lombiq.DataTable.Resources shape, for example in your theme. This is displayed before the Lombiq.DataTable shape, but after the basic configurations have been initialized (note: not applicable to the <datatable> tag helper).

Here you can edit the window.dataTableResources object. It contains the following properties:

  • options: a regular DataTables options object. For example use window.dataTableResources.options.dom to set the table layout for your theme.
  • created: a callback (function (wrapperElementJQuery, plugin)) that's executed after the plugin has been initialized. This is the ideal place for adding custom controls.

With Events

You can use all the regular DataTables events, but we've also implemented some custom ones. While DataTables events use the .dt namespace, these use the .lombiqdt namespace to avoid future conflict. They target the same DataTable element.

  • popstate.lombiqdt: fired after a history back/forward between different states of the table. The event is { plugin: jQueryPlugin, state: { providerName, data, order }, cancel: false }. Change cancel to true if you don't want to load this history.
  • createstate.lombiqdt: fired before a new DataTable history state is placed. The event is { plugin, state } and you can alter the state object from the event handler.
  • preXhr.lombiqdt: fired inside the options.ajax function right before the web request is sent out. The event is { plugin, requestData, isHistory }. You can change requestData here.

Vue.js Alternative

You may say, I Can't Believe It's Not DataTable! but it really is not. Use the <icbin-datatable> component for scenarios where you need something that matches the look and feel of DataTables and is a reusable Vue component with MVVM style logic.

<div id="my-app-id" class="my-app">
    <icbin-datatable v-model="data"
                     :columns="columns"
                     :text="text"
                     @@special="onSpecial">
        <div>Content here goes between the page length picker and the table.</div>
    </icbin-datatable>
</div>
  • data: a serialized array of VueModel (v-model here refers to the data property and the update event).
  • columns: a serialized array of DataTableColumnDefinition.
  • text: an object of keys and display texts (i.e. string-string dictionary). Its expected properties are: lengthPicker, displayCount, previous, next.
  • onspecial: a function that receives a cell that has the VueModel.Special property and can edit it.

For additional properties and notes on the events take a look at the comments in the component.

Note: Use @Json.Serialize() to automatically camelCase the data for JS.

Dependencies

This module has the following dependencies:

Troubleshooting

Visual Studio 2022

If you get the IntelliSense-only error TS6053 File "(...)/types/types.d.ts" not found. The file is in the program because: The root file specified for compilation_ you need to disable automatic type acquisition. This problem isn't present in VS2019 or third party IDEs, and it's cause by the Javascript Language Service. Solution:

  1. From the menu select Tools → Options.
  2. From the sidebar select Text Editor → JavaScript/Typescript → Project → General.
  3. Scroll down and uncheck Enable automatic type acquisition (TS 4.1 or later).

Contributing and support

Bug reports, feature requests, comments, questions, code contributions and love letters are warmly welcome. You can send them to us via GitHub issues and pull requests. Please adhere to our open-source guidelines while doing so.

This project is developed by Lombiq Technologies. Commercial-grade support is available through Lombiq.

orchard-data-tables's People

Contributors

0liver avatar barthamark avatar benedekfarkas avatar csuhi29 avatar demeszabolcs avatar dministro avatar domonkosgabor avatar i3undy avatar luko6 avatar mzole avatar piedone avatar porgabi avatar psichorex avatar sarahelsaig avatar wasnk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

aestrad

orchard-data-tables's Issues

ExportTableShouldMatchExpectation fails but only on GitHub-hosted runners (OSOE-624)

The ExportTableShouldMatchExpectation started to fail on its own with the below error. However, this only seems to happen when using GitHub-hosted runners; on GitRunners ones, that run for issue branches, this test is still OK (see OSOCE builds). See e.g. this and this failing build. The problem started some time after the 7th, since this build passed, then this one was the first one to fail, all without any change to this project. The runner was updated between the two, the passing build uses the Ubuntu image 20230426.1, the failing one 20230507.1.

[Lombiq.DataTables.Tests.UnitTests.Services.ExportTests ► ExportTableShouldMatchExpectation(note: "Make last column not exportable.", dataSet: [[1, "z", "foo"], [2, "y", "bar"], [10, "x", "baz"]], columns: [(Num, Numbers, True), (Letters, Letters, True)...: src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx#L1](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/commit/d188833edce0fc6e40e73d01d28468ac031e8fc8#annotation_11212487144)
Failed test found in:
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
  src/Modules/Lombiq.DataTables/Lombiq.DataTables/Tests/Lombiq.DataTables.Tests/TestResults/test-results.trx
Error:
  SixLabors.Fonts.MissingFontTableException : Table 'loca' is missing

Jira issue

Update datatables npm packages to supported versions, remove Assets workaround (OSOE-404)

This is a follow-up issue to OSOE-84.

Problem

Currently, Lombiq.DataTables uses patched versions of datatables.net base on 1.10.25 and datatables.net-bs4 based on 3.2.2.

The patches should long be available in newer releases, and we should return to using regular npm package dependencies to manage them.

Solution

  1. Add datatables.net and datatables.net-bs4 back to package.json dependencies.
  2. Update all dependencies to stable releases.
  3. Remove the Assets/UnmanagedNodeModules folder.
  4. Adjust the nodejsExtensions.assetsToCopy config object in package.json to copy the respective files from there instead of UnmanagedNodeModules.
  5. Also remove .github\actions\spelling\excludes.txt.

Jira issue

Create a TableField (OSOE-583)

It would be nice to have a field for storing admin-editable static tabular data.

  • The content field settings would let you set the column count, column names (maybe even the types?)
  • The editor would use <icbin-datatable> so rows can be added and the content set.
  • It could have separate display types for either responsive Bootstrap table or DataTables table.

Jira issue

Create an SQL Query based provider (OSOE-337)

Implement an IDataTableDataProvider that lets the user create a custom table using parameterized SQL Queries without coding.

Context from here:

Would it be feasible to provide a basic general provider for Queries that you can use without writing any code (like on DotNest)?

Yes, but I think you'd have to implement some kind of column definition content type with custom editor to provide the human readable column names so it wouldn't be that trivial. Also have to think about the security aspect of user provided SQL queries.

Jira issue

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.