[javascript bug] Multi Column List View (mclv) bugs (build 400)  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 679
Joined: Thu Jun 19, 2014 7:30 pm

[javascript bug] Multi Column List View (mclv) bugs (build 400)

Post by Mathew »

I've run into two bugs on the mclv dialog type:
  1. If an empty string is assigned to any element on a row, it will crash PXCE if you select that row;
  2. It's not possible to set a row as selected when loading the table. It seems to ignore Select: true
To reproduce
The following dialog should have the row with Title "Definitions" selected, and if you select the row below that (empty title) it will crash the program:

Code: Select all

// sample multi column list view
{
    const dialogObject = {
        results: {},
        initialize (dialog) {
            dialog.load(
            {
                "dia1": this.results,
            });
        },
        commit (dialog) {
            var elements = dialog.store();
            this.results = this.getMCLVrow( elements["dia1"]);
        },
        // handler for the MCLV
        dia1 (dialog) {
            const row = this.getMCLVrow( dialog.store()["dia1"] );
            app.alert("Chapter: " + row.chapter + "\n Section: " + row.section + "\n Sub-section: " + row.sub + "\n Title: " + row.title);
        },
        // returns the selected row in a MCLV
        getMCLVrow( mclv ) {
            for (var i = 0; i < mclv.aRows.length; i++) {
                const row = mclv.aRows[i];
                // property .Select is true if selected
                if (row.Select) return row;
            }
        },
        description: {
            name: "Sample Multi Column List View", elements: [
                {   type: "mclv", item_id: "dia1", width: 400, height: 200 },
                {   type: 'ok_cancel'}]
        }
    };
    /* data for the multi-column list view is an object with two properties aColmns and aRows
    *   aColumns is an array of columns. Each column has properties 
    *       Name (the property id to use in the rows), 
    *       UI (the displayed text), 
    *       width ( _proportion_ that this column should take of overall width), 
    *       Justification (I can't get this to work, so I don't know what properties of this do)
    *   aRows is an array with each item being an object with the properties defined in aColumns
    */
    dialogObject.results = {
        aColumns: [
            { Name: 'chapter', UI: "Chapter", width: 0.1},
            { Name: 'section', UI: "Section", width: 0.1},
            { Name: 'sub', UI: "Sub Section", width: 0.1},
            { Name: 'title', UI: "Title", width: 0.7}
            ],
        aRows: [
            { chapter: 1, section: 1, sub: 1, title: "SCOPE"},
            { chapter: 1, section: 2, sub: 1, title: "Definitions", Select: true}, // this row should be selected
            { chapter: 1, section: 3, sub: 2, title: ""}, // empty string will crash
            { chapter: 1, section: 3, sub: 3, title: "As-Built Information"},
            ]
    };
    // run the dialog
    app.execDialog( dialogObject);
    // this is what the MCLV returns from dialog.store();
    console.println(JSON.stringify(dialogObject.results, null, 2));
}
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11735
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript bug] Multi Column List View (mclv) bugs (build 400)

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for the heads up, I have passed it along to the Dev team for review, and will let you know if we have any news!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3593
Joined: Thu Jul 08, 2004 10:36 pm

Re: [javascript bug] Multi Column List View (mclv) bugs (build 400)

Post by Ivan - Tracker Software »

Thanks for the report.

Both issues are fixed in 10.7.3.
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Mathew
User
Posts: 679
Joined: Thu Jun 19, 2014 7:30 pm

Re: [javascript bug] Multi Column List View (mclv) bugs (build 400)

Post by Mathew »

Wow that was fast! :shock:

I noticed a similar issue with 'list_box' and 'popup' : the application crashes if a row with empty string '' is selected:

This example with list_box, but same with popup

Code: Select all

app.execDialog({
    initialize(dialog) {
        dialog.load({
            'txvw': {
                "First row": -1,
                "": 2, // empty string key will crash the app if selected
                "Third row": -3,
            }
        });
    },
    commit(dialog) {
        // app will crash trying to get the dialog.store()
        console.println(JSON.stringify(dialog.store()));
    },
    description: { name: "Test List View", elements: [
        { type: 'list_box', item_id: 'txvw', width: 200, height: 200},
        { type: 'ok'}]
    }
});
hier_list_box seems fine.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11735
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript bug] Multi Column List View (mclv) bugs (build 400)  SOLVED

Post by Daniel - PDF-XChange »

Hello, Mathew

And another quick fix! These will also be in 10.7.3

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com