<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ddubois2</title>
    <description>The latest articles on DEV Community by ddubois2 (@ddubois2).</description>
    <link>https://dev.to/ddubois2</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F514405%2Fb63704c1-8d78-434b-a01d-3f837ca41021.png</url>
      <title>DEV Community: ddubois2</title>
      <link>https://dev.to/ddubois2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ddubois2"/>
    <language>en</language>
    <item>
      <title>Cols not updating after select list changing</title>
      <dc:creator>ddubois2</dc:creator>
      <pubDate>Fri, 12 Mar 2021 19:04:59 +0000</pubDate>
      <link>https://dev.to/ddubois2/cols-not-updating-after-select-list-changing-2h2o</link>
      <guid>https://dev.to/ddubois2/cols-not-updating-after-select-list-changing-2h2o</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I use react Grid-layout, thanks to the developers for this superb work.&lt;/p&gt;

&lt;p&gt;On the other hand, I do not understand why the number of column does not update in my table.&lt;/p&gt;

&lt;p&gt;In fact, this.props.cols.lg is either 17 or 24.&lt;/p&gt;

&lt;p&gt;When it's 17, my table is displayed correctly. On the other hand, when I choose a period with 24 columns, my columns are placed one below the other from the 18th.&lt;/p&gt;

&lt;p&gt;this.props.cols.lg to the correct value (17 or 24) but my HTML page does not update to the design level.&lt;/p&gt;

&lt;p&gt;This is the right table &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.dropbox.com/s/2qymjbmtnjflvka/Capture%20d%E2%80%99%C3%A9cran%202021-03-12%20%C3%A0%2019.37.45.png?dl=0"&gt;https://www.dropbox.com/s/2qymjbmtnjflvka/Capture%20d%E2%80%99%C3%A9cran%202021-03-12%20%C3%A0%2019.37.45.png?dl=0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and the bad table &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.dropbox.com/s/2gkayc4veazlg2c/Capture%20d%E2%80%99%C3%A9cran%202021-03-12%20%C3%A0%2019.37.57.png?dl=0"&gt;https://www.dropbox.com/s/2gkayc4veazlg2c/Capture%20d%E2%80%99%C3%A9cran%202021-03-12%20%C3%A0%2019.37.57.png?dl=0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IMPORTANT :&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.props.cols.lg=loopValue+1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;contains the right value (17 or 25 cols) but it does not apply to my site.&lt;/p&gt;

&lt;p&gt;Thank you in advance for your help.&lt;/p&gt;

&lt;p&gt;Here is a part of my code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useEffect, Fragment } from 'react';
import { WidthProvider, Responsive } from "react-grid-layout";
import ReactTooltip from 'react-tooltip';
import _ from "lodash";
import { Button, Container } from 'react-bootstrap';
const ResponsiveReactGridLayout = WidthProvider(Responsive);
import { Responsive as ResponsiveGridLayout } from 'react-grid-layout';
/**
 * This layout demonstrates how to use a grid with a dynamic number of elements.
 */
export class AddRemoveLayout extends React.PureComponent {
    //les propriétés par défaut
    static defaultProps = {
        className: "layout border-darken-1 child-background-color",
        cols:
        { lg: 10, md: 10, sm: 10, xs: 10, xxs: 10 },
        width: 1000,
        margin: [0, 0],
        preventCollision: true,
        autoSize: true,
      //  preventCollision: true,
        rowHeight: 70,

    // Build HTML to insert
    render() {


        //Week
        let createDateItem =
            (x, y, day) =&amp;gt; ({
                i: `date-${x}_${y}`,
                x,
                y,
                w: 1,
                h: 1,
                myText: `${day}` ,
                static: true
            });
        /**
         *
         * @param {*} y
         * @param {*} xStart
         * @param {num semaine} dateStart
         * @param {nombre semaine total} count
         */

        let getDateItems =
            (y, xStart, dateStart, count,dateEnd) =&amp;gt; {
                let items = [];

                let loopValue = 0;

                while(dateStart&amp;lt;=dateEnd){//semainee
                    if(loopValue&amp;gt;1){
                        dateStart.setDate(dateStart.getDate() + 7)
                    }
                    if(dateStart&amp;lt;=dateEnd){
                    items.push(
                        createDateItem(xStart + loopValue, y,  loopValue === 0 ? 0 :
                           (dateStart.getDate()+"/" +(dateStart.getUTCMonth()+1)+ " (Sem. "+loopValue +") ")
                        ))
                    }
                    loopValue++;
                }

               console.log('props:')
               console.log(this.props);
               this.props.cols.lg=loopValue+1;
               this.props.cols.md=loopValue+1;
               this.props.cols.sm=loopValue+1;
               this.props.cols.xs=loopValue+1;
               this.props.cols.xxsloopValue+1;
               console.log(this.props);

               // console.log(AddRemoveLayout.defaultProps)

                return items;
            }
            ;
    ```



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>React-grid-layout into a table</title>
      <dc:creator>ddubois2</dc:creator>
      <pubDate>Sun, 22 Nov 2020 18:45:26 +0000</pubDate>
      <link>https://dev.to/ddubois2/react-grid-layout-into-a-table-38ge</link>
      <guid>https://dev.to/ddubois2/react-grid-layout-into-a-table-38ge</guid>
      <description>&lt;p&gt;Hello&lt;/p&gt;

&lt;p&gt;I'm using react-grid-layout with Laravel 7, AdminLTE and I have a good result yet :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AeJ1OJJO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bqg3mqsfbyglwhu3d4se.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AeJ1OJJO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bqg3mqsfbyglwhu3d4se.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I would like to put this result in a table as shown below to have headers and rows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CyzqclrH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ddypuexnudvvn4hel8dp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CyzqclrH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ddypuexnudvvn4hel8dp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KSAtAc5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a1mlepmtoh6srli433bj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KSAtAc5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a1mlepmtoh6srli433bj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you advise me to do this in reactjs or in simple html?&lt;/p&gt;

&lt;p&gt;If you have a sample code, I'm interested.&lt;/p&gt;

&lt;p&gt;This is my code :&lt;/p&gt;

&lt;p&gt;import React from 'react';&lt;br&gt;
import { WidthProvider, Responsive } from "react-grid-layout";&lt;br&gt;
import _ from "lodash";&lt;/p&gt;

&lt;p&gt;const ResponsiveReactGridLayout = WidthProvider(Responsive);&lt;br&gt;
/**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This layout demonstrates how to use a grid with a dynamic number of elements.&lt;br&gt;
*/&lt;br&gt;
export class AddRemoveLayout extends React.PureComponent {&lt;br&gt;
static defaultProps = {&lt;br&gt;
    className: "layout",&lt;br&gt;
    cols: { lg: 7, md: 10, sm: 6, xs: 4, xxs: 2 },&lt;br&gt;
    rowHeight: 100,&lt;br&gt;
    preventCollision: true,&lt;br&gt;
    verticalCompact: false // //you may want to turn off vertical compacting so items can be placed anywhere in the grid. Set the property &lt;code&gt;verticalCompact&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; to achieve this effect.&lt;/p&gt;

&lt;p&gt;};&lt;/p&gt;

&lt;p&gt;onLayoutChange(layout) {&lt;br&gt;
    /&lt;em&gt;eslint no-console: 0&lt;/em&gt;/&lt;br&gt;
    saveToLS("layout", layout);&lt;br&gt;
    this.setState({ layout });&lt;br&gt;
    this.props.onLayoutChange(layout); // updates status display&lt;br&gt;
    if (global.localStorage) {&lt;br&gt;
        try {&lt;br&gt;
          ls = JSON.parse(global.localStorage.getItem("rgl-7")) || {};&lt;br&gt;
          console.log(ls);&lt;br&gt;
        } catch (e) {&lt;br&gt;
          /&lt;em&gt;Ignore&lt;/em&gt;/&lt;br&gt;
        }&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;constructor(props) {&lt;br&gt;
    super(props);&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.state = {
    items: [0, 1, 2, 3, 4].map(function (i, key, list) {
        return {
            i: i.toString(),
            x: i * 2,
            y: 0,
            w: 2,
            h: 2,
            //add: false                    //You can add an item by clicking here, too
        };
    }),
    newCounter: 0
};

this.onAddItem = this.onAddItem.bind(this);
this.onBreakpointChange = this.onBreakpointChange.bind(this);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;createElement(el) {&lt;br&gt;
    const removeStyle = {&lt;br&gt;
        position: "absolute",&lt;br&gt;
        right: "2px",&lt;br&gt;
        top: 0,&lt;br&gt;
        cursor: "pointer"&lt;br&gt;
    };&lt;br&gt;
    const i = el.add ? "+" : el.i;&lt;br&gt;
    return (&lt;br&gt;
        &lt;/p&gt;

            {el.add ? (
                &lt;span&gt;
                    className="add text"&lt;br&gt;
                    onClick={this.onAddItem}&lt;br&gt;
                    title="You can add an item by clicking here, too."&lt;br&gt;
                &amp;gt;&lt;br&gt;
                    Add +&lt;br&gt;
                &lt;/span&gt;
            ) : (
                    &lt;span&gt;{i}&lt;/span&gt;
                )}
            &lt;span&gt;
                className="remove"&lt;br&gt;
                style={removeStyle}&lt;br&gt;
                onClick={this.onRemoveItem.bind(this, i)}&lt;br&gt;
            &amp;gt;&lt;br&gt;
                x&lt;br&gt;
    &lt;/span&gt;
        
    );
}

&lt;p&gt;onAddItem() {&lt;br&gt;
    /&lt;em&gt;eslint no-console: 0&lt;/em&gt;/&lt;br&gt;
    console.log("adding", "n" + this.state.newCounter);&lt;br&gt;
    this.setState({&lt;br&gt;
        // Add a new item. It must have a unique key!&lt;br&gt;
        items: this.state.items.concat({&lt;br&gt;
            i: "n" + this.state.newCounter,&lt;br&gt;
            x: (this.state.items.length * 2) % (this.state.cols || 12),&lt;br&gt;
            y: Infinity,&lt;br&gt;
            w: 2,&lt;br&gt;
            h: 2&lt;br&gt;
        }),&lt;br&gt;
        // Increment the counter to ensure key is always unique.&lt;br&gt;
        newCounter: this.state.newCounter + 1&lt;br&gt;
    });&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// We're using the cols coming back from this to calculate where to add new items.&lt;br&gt;
onBreakpointChange(breakpoint, cols) {&lt;br&gt;
    this.setState({&lt;br&gt;
        breakpoint: breakpoint,&lt;br&gt;
        cols: cols&lt;br&gt;
    });&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;onLayoutChange(layout) {&lt;br&gt;
    this.props.onLayoutChange(layout);&lt;br&gt;
    this.setState({ layout: layout });&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;onRemoveItem(i) {&lt;br&gt;
    console.log("removing", i);&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.setState({ items: _.reject(this.state.items, { i: i }) });
console.log(this.state);//
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;render() {&lt;br&gt;
    return (&lt;br&gt;
        &lt;/p&gt;

            Add Item
            
                onLayoutChange={this.onLayoutChange}
                onBreakpointChange={this.onBreakpointChange}
                {...this.props}
            &amp;gt;
                {_.map(this.state.items, el =&amp;gt; this.createElement(el))}
            
        
    );
}
}&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you in advance.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>react</category>
    </item>
    <item>
      <title>How to install react-grid-Layout ?</title>
      <dc:creator>ddubois2</dc:creator>
      <pubDate>Sat, 14 Nov 2020 14:21:21 +0000</pubDate>
      <link>https://dev.to/ddubois2/how-to-install-react-grid-layout-4h3f</link>
      <guid>https://dev.to/ddubois2/how-to-install-react-grid-layout-4h3f</guid>
      <description>&lt;p&gt;Hello and thank you in advance for your  help.&lt;/p&gt;

&lt;p&gt;I'm a reactjs beginner.&lt;/p&gt;

&lt;p&gt;I would like to use this reactjs tool :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/STRML/react-grid-layout"&gt;https://github.com/STRML/react-grid-layout&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I create a folder in htdocs, I clone the project.&lt;/p&gt;

&lt;p&gt;Have I also use npm after the clone ?&lt;/p&gt;

&lt;p&gt;I see this, but I'm not able to make something else :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TXLm2g3m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3x2bgxlpfkt0u0rnjxm1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TXLm2g3m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3x2bgxlpfkt0u0rnjxm1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you in advance for your help and sorry for this question&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
