logo
down
shadow

How can I build a dataTable, with a dropbox filter on top, calculated on backend?


How can I build a dataTable, with a dropbox filter on top, calculated on backend?

By : user3045464
Date : December 02 2020, 10:46 PM
Hope this helps I need to change a dataTable to add a dropbox on top of it (not in the header) to filter it. , Found the solution :
HTML :
code :
<select name="filtre_saison" id="filtre_saison">
</select>

<table>
    ...
</table>
"initComplete": function() {
    if ($(this).attr('id') == "tableBuildings") {
        var dates = $('#tableBuildings tr td:first-child').toArray();

        populate_dropdown(dates);

        $.fn.dataTable.ext.search.push( function( settings, data, dataIndex, rowData, counter ) {
            if (settings.nTable.id === 'tableBuildings') {

                //Calculation of beggining and ending of the room
                var yearsBuildig = $("#filtre_saison").val().split(' ')[1];
                var initialDate = new Date(yearsBuildig.split('/')[0],10,01);
                var endDate = new Date(initialDate.getFullYear() + 1, initialDate.getMonth(), initialDate.getDate());

                //Calculation of the Date object of the PFHA
                var year = Number(rowData.initialDate.display.split(' ')[0].split('/')[2]);
                var month = Number(rowData.initialDate.display.split(' ')[0].split('/')[1] - 1);
                var day = Number(rowData.initialDate.display.split(' ')[0].split('/')[0]);
                var hours = Number(rowData.initialDate.display.split(' ')[1].split(':')[2]);
                var buildingDate = new Date(year, month, day);

                if (buildingDate >= initialDate && buildingDate < endDate) {
                    return true;
                } else {
                    //this row doesn't contain that year, let's hide the whole <tr>
                    return false;
                }

            } else {
                return true;
            }
        });

        $('#filtre_saison').on('change', function() {
            table.draw();
        });

        table.draw();
    }
}

function populate_dropdown(dates) {
    // make an empty array variable to hold the list of building
    var building = [];

    // loop through the dates
    for (var i = 0; i < dates.length; i++) {

        var year = Number($(dates[i]).html().split(' ')[0].split('/')[2]);
        var month = Number($(dates[i]).html().split(' ')[0].split('/')[1] - 1);
        var day = Number($(dates[i]).html().split(' ')[0].split('/')[0]);
        var buildingDate = new Date(year, month, day);

        var initialDateRoom = new Date(year, 10, 1);

        // now let's calculate the room
        var room;
        if (buildingDate < initialDateRoom) {
            room = Number(year-1) + "/" + year;
        } else {
            room = year + "/" + Number(year+1);
        }

        // now let's add that room to the building array (if it's not already in the array!)
        if ($.inArray(room, building) == -1) {
            building.push(room);
        }
    }

    // now that we're done looping through and building the building list, let's sort the array
    building.sort();

    // make a variable to hold all the <option> fields for the select dropdown
    var options = "";

    // loop through the years and make the options fields
    $.each(building, function(key,value) {
        options += "<option> room " + value + "</option>";
    }); 

    // take the new options string that we've built and put it inside the <select> dropdown
    $('#filtre_saison').append(options);
}
if (settings.nTable.id === 'tableBuildings')


Share : facebook icon twitter icon
Compare Row of 1st Datatable with Column of 2nd Datatable and build 3rd datatable with matched columns

Compare Row of 1st Datatable with Column of 2nd Datatable and build 3rd datatable with matched columns


By : Joni Lawlor
Date : March 29 2020, 07:55 AM
wish helps you As others have said, this is straight forward logic and that you should try it yourself first. This will give you confidence as well.
Anyways, the following code should do the trick. Tweek it as per your convenience. Also test it thoroughly.
code :
//dt1 contains Diffusion etc as rows
//dt2 contains diffusion etc as columns
//dt3 is the required table
DataTable dt3 = new DataTable();
DataRow dr = null;

for (int i = 0; i < dt1.Rows.Count; i++)
{
    string col = dt1.Rows[i]["Par Name"].ToString();
    if (dt2.Columns.Contains(col))
    {
        if (!dt3.Columns.Contains(col))
        {
            dt3.Columns.Add(col, typeof(string));
        }

        if (dt3.Rows.Count == 0)
        {
            for (int j = 0; j < dt2.Rows.Count; j++)
            {
                dr = dt3.NewRow();
                dt3.Rows.Add(dr);
            }
        }

        for (int j = 0; j < dt2.Rows.Count; j++)
        {
            dt3.Rows[j][col] = dt2.Rows[j][col].ToString();
        }
    }
}
VB.Net Linq-to-datatable How to create a datatable based on an existing datable with filter

VB.Net Linq-to-datatable How to create a datatable based on an existing datable with filter


By : Renoir Pulitz
Date : March 29 2020, 07:55 AM
I hope this helps you . Based upon what you wrote in your comments, although I'm very confused as to why you would want it this way and think you should rather look at your code a bit more and see if there's a nicer / neater solution (for example, using DataViews that automatically allow for filtering).
The way I would do this would look as follows:
code :
Dim ReturnedTables As New List(Of DataTable)
Dim strings = From row In PlTable Select row.Field(Of String)(0)

For Each s As String In strings
    Dim Retval = From row In table.AsEnumerable
                 Where row.Field(Of String)("Name").Contains(s)
                 Select row

    If Retval.Count > 0 Then ReturnedTables.Add(Retval.CopyToDataTable)
Next
ReturnedTables(i).Rows.Count
Is it possible to substitute a server backend using Dropbox?

Is it possible to substitute a server backend using Dropbox?


By : Tsujmi
Date : March 29 2020, 07:55 AM
Hope that helps Dropbox cannot be a dependable substitute for your server/backend for following reasons:
How to we make a filter(from a calculated field) a context filter in Tableau

How to we make a filter(from a calculated field) a context filter in Tableau


By : Shanmuga Sundaram
Date : March 29 2020, 07:55 AM
Hope this helps You can't make table calculation filters into context filters.
Context filters are evaluated very early in the operation pipeline at the data source (aka database server). Table calculations are computed very late in the operation pipeline by Tableau (aka client).
code :
if rk < .5 then
  'Small'
elseif rk < .7 then 
  'Medium Small'
elseif rk < .9 then
  'Medium'
elseif rk < .95 then
  'Medium Large'
else
  'Large'
end
How do I upload images using dropbox API v2 in nodejs backend

How do I upload images using dropbox API v2 in nodejs backend


By : user2957047
Date : March 29 2020, 07:55 AM
may help you . I figured it out myself. Only posting in case anyone ever faces the same problem. The contents should be changed from image, to image.data
ie rather than doing this;
code :
dbx
      .filesUpload({
        path: `/${image.name}`,
        contents: image
      })
      .then(response => {
        console.log(response);
      })
      .catch(err => {
        console.log(err);
      });
dbx
      .filesUpload({
        path: `/${image.name}`,
        contents: image.data
      })
      .then(response => {
        console.log(response);
      })
      .catch(err => {
        console.log(err);
      });
Related Posts Related Posts :
  • redux how to use state
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to get css selector of clicked-on element?
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org