Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
jqgrid json data array insert

In jqgrid, the part checked in the checkbox is brought into an array and inserted into the DB through VO.

I got the row data checked in jqgrid multiselect and pushed it into the declared array.

objGrid.click(function(){

            var data = objGrid.jqGrid('getGridParam','selarrrow');
            for(var i =0; i<data.length; i++)
            {

                empsl = objGrid.jqGrid('getCell', data[i], 'empno');
                /* empsl = JSON.parse(empsl); */
                arry.push(empsl);
            }


            test = JSON.parse(arry);
            //test = JSON.stringify(arry);

            console.log(test);


        });
},
        
        buttons : {
            "저장":function() {        
                console.log(typeof arry);
                console.log("insert data",arry);
                
                 if (isRunning) {
                    alert($.message.common.notification.wait);
                    return;
                }
                isRunning = true; 
            
                    $.post("./CheckHoliday/addCheckHolidayData"
                            , {empsl:arry} 
                            , function(data){
                                if (data > 0) {
                                    alert("has been saved.");
                                    closeDialogFunc();
                                    CheckHolidayListRefresh();

When I convert to JSON.stringify and press the save button, it comes in as an array well, but as you can see, even parentheses and quotation marks are entered as it is, and an error occurs.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '["10010","10010","10049"],
'Y'
)' at line 7

So, if you think you need to change it to JSON.parse(arry); and convert it to parse

If only one data is selected in the checkbox, it will be saved successfully, but if more than one checkbox is selected,

Uncaught SyntaxError: Unexpected token , in JSON at position 5 at JSON.parse () at HTMLTableElement.eval (eval at (jquery-1.8.3.js:564), :102:17) at HTMLTableElement.dispatch (jquery-1.8.3.js:3058) at HTMLTableElement.eventHandle (jquery-1.8.3.js:2676)

This error pops up in the developer tools console window, but I can't seem to put it into an array.

The end goal is to put the selected data into an array.

INSERT INTO HRS_CHECKHOLIDAY (
EMPNO
, EMPSL
, USEYN
) VALUES (
${empno},
${empsl},
'Y'
)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Isn't arry an object? So you cannot JSON.parse(arry) and you must get an error. Stringify arry then post the string. That should work.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!