Adding data from textbox to grid

Posted by: nivishapanwar on 10 May 2021, 9:26 am EST

    • Post Options:
    • Link

    Posted 10 May 2021, 9:26 am EST

    Hello,

    How can I add the data I am giving in textbox into wijmo grid by clicking on add button.

    I have an add button, texbox and wijmo grid.

    In one of the columns of grid the data will be added by clicking on add button from textbox .

    Thank you.

    Regards,

    Nivisha Panwar

  • Posted 11 May 2021, 5:50 am EST

    Hi,

    To achieve the required functionality you may handle click event on Add button and inside it you may get the value of textarea and add data to grid’s particular column using setCellData method. In the code sample, I have added the textarea value to the selectedRow’s comments column cell.

    For better understanding, you may refer to the below code sample depicting the same -

    https://codesandbox.io/s/hopeful-http-k984s?file=/src/app/app.component.ts

    Regards

  • Posted 12 May 2021, 4:20 am EST

    Hello Sharad,

    Thank you for the help.

    But I am getting one error stating "cannot read property ‘value’ of null.

    Could you please help me with this.

    setComments(flexGrid) {

    let textarea = document.querySelector(“textarea”);

    flexGrid.setCellData(flexGrid.selectedRows[0].index, “comments”, textarea.value);

    textarea.value = “”;

    }

    label: ‘Add Role’,

    icon: ‘bento-icon-add-filled’,

    action: () => {

    this.setComments(this.flexGrid);

    }

    Regards,

    Nivisha PanwarError 1.zip

  • Posted 12 May 2021, 8:47 am EST

    Thank you, but now it is working as I have used ngmodel now.

  • Posted 13 May 2021, 1:26 am EST

    Thank you for sharing your approach. We are glad that the issue is resolved.

  • Posted 14 May 2021, 5:07 am EST

    Hi Sharad,

    Can we add that new record in dropdown. Like when we click on add ,the data should be added from the textbox to the column dropdown. For example we have country column, then in all rows in the grid the that column will have dropdown of the records.

    Could you please help me with this.

    Thank you.

    Regards,

    Nivisha Panwar

  • Posted 17 May 2021, 3:49 am EST

    Hi,

    You may push values to the dataMap array to show them in the dropdown. You may refer to the following sample which demonstrates the same:

    https://codesandbox.io/s/zealous-swartz-dj7rm?file=/src/app/app.component.ts

    Regards

    Sharad

  • Posted 19 May 2021, 5:25 am EST

    Thanks Sharad for the help.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels