Author Topic: Context header for add/delete columns  (Read 3021 times)

Jignesh

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Context header for add/delete columns
« on: November 20, 2019, 08:08:27 pm »
Hi,

I have a problem for add/delete columns on context header.

 I have set context-click event but not understand how to add/delete columns as
    {
                title: "Data", align: "center", colModel: [
                    {
                        title: "", width: 50, dataType: "bool", menuInDisable: true,                     
                        render: function (ui) {
                            var rowData = ui.rowData,
                                dataIndx = ui.dataIndx;
                                ldataIndx = 6;

                            rowData.pq_cellcls = rowData.pq_cellcls || {};
                            if (rowData["Skip"] == true) {
                                rowData.pq_cellcls[dataIndx] = 'grey';
                                rowData.pq_cellcls[ldataIndx] = 'grey';
                                return "<input type='checkbox' " + (ui.cellData ? "checked='checked'" : "") + " />";
                            }
                            else {
                                rowData.pq_cellcls[dataIndx] = '';
                                rowData.pq_cellcls[ldataIndx] = '';
                                return "<input type='checkbox' " + (ui.cellData ? "checked='checked'" : "") + " />";
                            }
                        },
                        align: "center", dataIndx: "Skip", exportRender: false, editor: false, type: 'checkbox', cls: 'hideRightborder'
                    },
                    { title: "Opics Test", width: 170, dataType: "string", cls: 'hideLeftborder', filter: { crules: [{ condition: 'contain' }] } }]
            },


formate with blank data.

Please give me some links or  some possible way to achieve add/delete columns like MS Excel.

Thank you,
Jigneh

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Context header for add/delete columns
« Reply #1 on: November 21, 2019, 10:40:33 am »
Jignesh

I've updated this demo to include Add / delete column functionality in header menu.

https://paramquery.com/pro/demos/context_menu

Hope it helps.

Jignesh

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Context header for add/delete columns
« Reply #2 on: November 21, 2019, 05:00:34 pm »
Thank you Paramvir,

Context add column successfully working.

But I have got an issue from Delete context columns: I have attached a screenshot.
A scenario like 1) I have added new 3 columns with different titles by context menu in the last column list. 
                      2) I have tried to delete the second last column by context delete but columns have not deleted as display in screenshots.
                      3) But if I delete column as "OPICS_FX_SPOT_Purchase" yellow underline in a screenshot and delete then last column delete.

I have parent child columns structure like :  Parent column title = "OPICS_FX_SPOT_Purchase"
                                                                  Childs columns = 1) checkbox column with blank title
                                                                                             2) string column with data.

I have already given column structure in the first question in this thread.

Please give me help for resolve this scenario.

Thank you,
Jignesh
« Last Edit: November 21, 2019, 05:10:58 pm by Jignesh »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Context header for add/delete columns
« Reply #3 on: November 21, 2019, 05:03:42 pm »
What's the issue. Please share a jsfiddle.

Jignesh

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Context header for add/delete columns
« Reply #4 on: November 21, 2019, 05:13:45 pm »
Can I show you by teamview or remote ?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Context header for add/delete columns
« Reply #5 on: November 22, 2019, 11:18:30 am »
Got it.

Previous code for Add/Delete columns was for non-grouped columns only.

Please refer to the updated script for grouped  columns in this demo and adapt it to your needs:

https://paramquery.com/pro/demos/context_menu