Okay
  Public Ticket #1604551
Dynamic queries
Open

Comments

  • Ariel started the conversation

    hi,

    Before I purchase I wanted to make sure I can build charts based on dynamic queries, composed of drop down selections from the user.

    Thanks!

  •  200
    Milos replied

    Hi Ariel,
    Thank you for the inquiry.

    Can you please describe me your inquiry in more details? Do you want to build dynamic charts or tables? When user select something from the dropdown filter, you want to filter table/chart also?

    You can try our sandbox site: Front-end & Back-end - you can find a fully functional version there to try out all plugin features.

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Milos Timotic
    milos.timotic@touchmesoft.net

  • Ariel replied

    Hi Milos,

    yes, i need exactly what you described -  

    "i want to build dynamic charts so when user selects something from the dropdown filter it will filter table/chart ,

    possible?

  •  200
    Milos replied

    Hi Ariel,

    Something like that is possible. You have to have both wpDataTable and wpDataChart on the page. While you are creating chart you have to enable "Follow table filtering" feature to achieve this. You can take a look at it on this page from our documentation - Follow table filtering in charts.

    For example on this page you can try to filter "Type" column by selecting some value in the drop-down and you will see that chart will update it's data based on selected value.

    You can try our sandbox site: Front-end & Back-end - you can find a fully functional version there to try out all plugin features.

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Milos Timotic
    milos.timotic@touchmesoft.net

  • Ariel replied

    Hi and thanks.

    it's not enough, i cant show the table to my customers, only the final chart.

    Moreover, i have to give them independent dropdowns (i mean not as part of any table)  from which each selection will create a dynamic query, which in turn will fire the chart to change according to the new data.

    is it possible in your plugin?

  •  200
    Milos replied

    Hi Ariel,

    It is possible but with small custom CSS code that we can send to you. Yes, filters can be independent from the table. You can take a look at this page how filters are in the form above the table. https://wpdatatables.com/documentation/table-features/advanced-filtering/#advanced-filter

    You can hide the table with CSS so it will not be visible (just filters will be visible), and then when you change the values in the filters, the chart will be updated.

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Milos Timotic
    milos.timotic@touchmesoft.net

  • Ariel replied

    I and thanks again:-)

    i need the flexibility of just sending my sql query to the chart and the chart will change.

    is it possible?

    (im a developer so even if it means a small "touch" in PHP it's ok)

  •  200
    Milos replied

    Hi Ariel,

    When you are filtering the wpDataTable that is created from MySQL query it will automatically add WHERE clause on the query. For example if you create wpDataTable from:

    SELECT * FROM table_name

    when you filter the wpDataTable column called e.g. "a", our plugin will automatically add WHERE and query that will be sent to database will be:

    SELECT * FROM table_name WHERE a LIKE '%some value%'

    It is possible to intercept the query using hooks. The hook you need to use is wpdatatables_filter_mysql_query($query, $tableId)

    "This filter is applied to the MySQL query before it is sent to MySQL server.

    $query is the query text

    $tableId is the table identifier from the MySQL table (wp_wpdatatables)."

    You can take a look at all available hooks on this documentation page.

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Milos Timotic
    milos.timotic@touchmesoft.net

  • Ariel replied

    Thanks again, still i want to ne precise:

    if i intercept the query can i build query with a join of two tables + group by?

    lets say i want to display in the chart expenses of salaries of employees in the company per year:

    select salaries.year, sum(12*salaries.month_salary)  as  TotalEmployeesExpenses

    from employees inner join salaries 

    on employees.id = salaries.id

    group by salaries.year

    thanks!

  •  200
    Milos replied

    Hi Ariel,

    You can build query with a join of two tables but you will have to have the same number of the columns (and the name of the columns) like in the table that you created. Can you explain me why would you need this? Why can't you use joins directly when you create wpDataTable?

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Milos Timotic
    milos.timotic@touchmesoft.net