Jump to content
#StayAtHome ×

mongoose00318

Members
  • Content Count

    53
  • Joined

  • Last visited

Community Reputation

0 Neutral

About mongoose00318

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. Haha yea...I thought it was super up-to-date. I was disappointed to find out it's from '09...thanks
  2. Okay...turns out that function is depreciated. Using addBack() fixed the problem. Can I mark this as the answer to my question? Or should I just delete the post?
  3. Hi, I am trying to get refreshed on jQuery so I bought O'Reillys jQuery cookbook. I'm having trouble with the exercise on using andSelf() to manipulate the parent of the selected element; though my code is exactly like the books. <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <div> <p>Paragraph</p> <p>Paragraph</p> </div> <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"> </script> <script> $('div').find('p').andSelf().css('border', '1px solid #993300'); </script> </body> </html> From my understanding my jQuery should add a border to the <div> but it doesn't. When I remove andSelf() it does add a border to the 2 <p> tags though. Am I doing something wrong?
  4. About the PHPEnthusiast article you recommended...what would the dummy API look like? The one he says returns a random number. Is it something you would have several functions in it and call using a _GET request or something?
  5. That did it...https://pastebin.com/KwH5VUdB Now, the only problem is when a parent doesn't have more than 1 child. Like in the pastebin example...it isn't listing the one child it has. I think it has to do with my if() else() statement because when I do this: //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { if ($checkJob == $job_number) { print "<b>checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "</b><br>"; } else { $checkJob = $job_number; print "checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "<br>"; } } Even though the first lines match, it never makes them bold. It comes out like this: checkJob: 22359501 | currentJob: 22359501 checkJob: 22359501 | currentJob: 22359501 checkJob: 22359501 | currentJob: 22359501 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841
  6. That did it...https://pastebin.com/KwH5VUdB Now, the only problem is when a parent doesn't have more than 1 child. Like in the pastebin example...it isn't listing the one child it has. I think it has to do with my if() else() statement because when I do this: //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { if ($checkJob == $job_number) { print "<b>checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "</b><br>"; } else { $checkJob = $job_number; print "checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "<br>"; } } Even though the first lines match, it never makes them bold. It comes out like this: checkJob: 22359501 | currentJob: 22359501 checkJob: 22359501 | currentJob: 22359501 checkJob: 22359501 | currentJob: 22359501 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841 checkJob: 22564841 | currentJob: 22564841
  7. When I change my line to that...the JSON goes crazy... //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { if ($checkJob == $job_number) { //print "<b>checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "</b><br>"; $json['__children'][] = array( 'LN #' => $line_item, 'Description' => $description, 'Qty' => $qty, 'AS400 Ship Date' => $as400_ship_date, 'Date Showed on Report' => $date_showed_on_report, 'Days to Manufacture' => "5", 'Notes' => $notes, 'Date Shown Completed' => $date_shown_complete, 'Actual Ship Date' => $actual_ship_date, 'Qty Shipped' => $qty_shipped ); } else { $checkJob = $job_number; //print "checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "<br>"; $json[] = array( 'Job Number' => $job_number, 'LN #' => null, 'Description' => null, 'Qty' => null, 'AS400 Ship Date' => null, 'Date Showed on Report' => null, 'Days to Manufacture' => null, 'Notes' => null, 'Date Shown Completed' => null, 'Actual Ship Date' => null, 'Qty Shipped' => null, ); } } It just starts putting a bunch of children with parents that those children aren't related to: { "0": { "Job Number": "22359501", "LN #": null, "Description": null, "Qty": null, "AS400 Ship Date": null, "Date Showed on Report": null, "Days to Manufacture": null, "Notes": null, "Date Shown Completed": null, "Actual Ship Date": null, "Qty Shipped": null }, "_children": [ { "LN #": "A", "Description": "SHELL GLOBAL 6x6 ID DF TP SGN (SH RVI)||ENG: SE1066RF_SH; RTE: 66SHID||5 ROWS SIGNBOX 2 LEDS||", "Qty": "1", "AS400 Ship Date": "2020-01-17", "Date Showed on Report": "2019-12-28", "Days to Manufacture": "5", "Notes": "", "Date Shown Completed": "2020-01-17", "Actual Ship Date": "2020-02-27", "Qty Shipped": "1" }, { "LN #": "D", "Description": "SHELL GLOBAL 6' 1X FUEL REWARDS CHARGE||", "Qty": "2", "AS400 Ship Date": "2020-01-17", "Date Showed on Report": "2019-12-28", "Days to Manufacture": "5", "Notes": "", "Date Shown Completed": "2020-02-27", "Actual Ship Date": "2020-02-27", "Qty Shipped": "2" }, That example above has 500 something children now when in reality it only has 4 children...am I doing something different than you suggested?
  8. That's an interesting idea...I want to look into that more. At some point I will be using AJAX at the very least to update records with this. If you have any good reads you can suggest...I'd like to take a look at them if you don't mind. Okay, well....I got it working! At least somewhat... Here is my current code: $checkJob = ''; //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { if ($checkJob == $job_number) { //print "<b>checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "</b><br>"; $json[][] = array( 'LN #' => $line_item, 'Description' => $description, 'Qty' => $qty, 'AS400 Ship Date' => $as400_ship_date, 'Date Showed on Report' => $date_showed_on_report, 'Days to Manufacture' => "5", 'Notes' => $notes, 'Date Shown Completed' => $date_shown_complete, 'Actual Ship Date' => $actual_ship_date, 'Qty Shipped' => $qty_shipped ); } else { $checkJob = $job_number; //print "checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "<br>"; $json[] = array( 'Job Number' => $job_number, 'LN #' => null, 'Description' => null, 'Qty' => null, 'AS400 Ship Date' => null, 'Date Showed on Report' => null, 'Days to Manufacture' => null, 'Notes' => null, 'Date Shown Completed' => null, 'Actual Ship Date' => null, 'Qty Shipped' => null, ); } //$json[] = array($description, $qty, $line_item, $job_number, $as400_ship_date, $date_showed_on_report, "5", $notes, $date_shown_complete, $actual_ship_date, $qty_shipped); } My only problem is how the JSON is coming out...it's structured like this right now: [ { "Job Number": "22359501", "LN #": null, "Description": null, "Qty": null, "AS400 Ship Date": null, "Date Showed on Report": null, "Days to Manufacture": null, "Notes": null, "Date Shown Completed": null, "Actual Ship Date": null, "Qty Shipped": null }, [ { "LN #": "A", "Description": "SHELL GLOBAL 6x6 ID DF TP SGN (SH RVI)||ENG: SE1066RF_SH; RTE: 66SHID||5 ROWS SIGNBOX 2 LEDS||", "Qty": "1", "AS400 Ship Date": "2020-01-17", "Date Showed on Report": "2019-12-28", "Days to Manufacture": "5", "Notes": "", "Date Shown Completed": "2020-01-17", "Actual Ship Date": "2020-02-27", "Qty Shipped": "1" } ], ] I need it to be like this though... [ { 'Job Number': '22983321', 'LN #': null, 'Description': null, 'Qty': null, 'AS400 Ship Date': null, 'Date Showed on Report': null, 'Days to Manufacture': null, 'Notes': null, 'Date Shown Completed': null, 'Actual Ship Date': null, 'Qty Shipped': null, __children: [ { 'LN #': 'A', 'Description': 'Text for description goes here..', 'Qty': 1, 'AS400 Ship Date': '2020-03-13', 'Date Showed on Report': '2020-02-25', 'Days to Manufacture': 5, 'Notes': 'Text for notes here..', 'Date Shown Completed': '2020-03-17', 'Actual Ship Date': '2020-03-17', 'Qty Shipped': 1, }, { 'LN #': '3', 'Description': 'Text for description goes here..', 'Qty': 1, 'AS400 Ship Date': '2020-03-13', 'Date Showed on Report': '2020-02-25', 'Days to Manufacture': 5, 'Notes': 'Text for notes here..', 'Date Shown Completed': '2020-03-17', 'Actual Ship Date': '2020-03-17', 'Qty Shipped': 1, }, ], ] It's the part that says __children: [ ] that I am missing...not sure where to go from here..but I know I'm getting close
  9. I sort of have it working though I don't know if this is the right way to go about it... $checkJob = ''; //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { if ($checkJob == $job_number) { print "<b>checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "</b><br>"; } else { $checkJob = $job_number; print "checkJob: " . $checkJob . " | " . "currentJob: " . $job_number . "<br>"; } $json[] = array($description, $qty, $line_item, $job_number, $as400_ship_date, $date_showed_on_report, "5", $notes, $date_shown_complete, $actual_ship_date, $qty_shipped); }
  10. I have a table which stores job numbers…each job number can have multiple “line items”…here is a screenshot of example data: https://imgur.com/qSaiJMD I am trying to use another feature of handsontable called nestedRows which makes it look like this: https://imgur.com/lRE6mbq In that example I have setup the JSON with hardcoded data. I am trying to integrate it into my PHP now. I have to make the JSON go from this: https://imgur.com/7hHQvC9 To something like this: https://imgur.com/7bSdl1O I can’t figure out how I can compare the current value in “job_number” to the last row’s “job_number” value so that I can tell the code for example… if($previousRow_job_number == $currentRow_job_number) { //then structure JSON data as a child (line item) of this job number } else { //structure JSON data as a parent job number } This is my current code I am trying to modify: <script type="text/javascript"> /* JSON Construction */ const data = <?php //setup query $sql = 'SELECT * FROM production_data'; //execute SQL transaction try { //prepare SQL statement & execute $stmt = $pdo->prepare($sql); $stmt->execute(); //bind column names to variables $stmt->bindColumn('id', $id); $stmt->bindColumn('job_number', $job_number); $stmt->bindColumn('enterprise', $enterprise); $stmt->bindColumn('part_number', $part_number); $stmt->bindColumn('description', $description); $stmt->bindColumn('qty', $qty); $stmt->bindColumn('line_item', $line_item); $stmt->bindColumn('as400_ship_date', $as400_ship_date); $stmt->bindColumn('date_showed_on_report', $date_showed_on_report); $stmt->bindColumn('shipping_method', $shipping_method); $stmt->bindColumn('notes', $notes); $stmt->bindColumn('date_shown_complete', $date_shown_complete); $stmt->bindColumn('actual_ship_date', $actual_ship_date); $stmt->bindColumn('qty_shipped', $qty_shipped); //output data into spreadsheet view while($row = $stmt->fetch(PDO::FETCH_BOUND)) { //construct array with data $json = array(); while($row = $stmt->fetch(PDO::FETCH_BOUND)) { //$json[] = array($description, $qty, $line_item, $job_number, $as400_ship_date, $date_showed_on_report, "5", $notes, $date_shown_complete, $actual_ship_date, $qty_shipped); $json[] = array($job_number, $line_item, $description, $qty, $as400_ship_date, $date_showed_on_report, "5", $notes, $date_shown_complete, $actual_ship_date, $qty_shipped); } //encode for JSON and output to screen print(json_encode($json)); } } //failed to execute SQL transaction catch (PDOException $e) { print $e->getMessage(); } ?> /* End JSON Construction */ const container = document.getElementById('productionLogTable'); const hot = new Handsontable(container, { data: data, //colHeaders: ['Description', 'Qty', 'LN #', 'Order Number', 'AS400 Ship Date', 'Date Showed on Report', 'Days to Manufacture', 'Notes', 'Date Shown Completed', 'Actual Ship Date', 'Qty Shipped'], colHeaders: ['Job Number', 'LN #', 'Description', 'Qty', 'AS400 Ship Date', 'Date Showed on Report', 'Days to Manufacture', 'Notes', 'Date Shown Completed', 'Actual Ship Date', 'Qty Shipped'], //colWidths: [300, 70, 70, 110, 110, 90, 90, 300, 90, 90], colWidths: [110, 70, 300, 70, 110, 90, 90, 300, 90, 90], rowHeaders: true, headerTooltips: { columns: true, onlyTrimmed: true }, filters: true, dropdownMenu: true, }); </script> I hope I’ve provided enough detail…
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.