Click here to Skip to main content
14,575,451 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi guys,

I have a question on merging data
1.How to use the colspan to merge the button in column based on the dynamic data?
Here are the image of my data in a table

using colspan

and here the coding for it in javascript:

var DrillStructure = {
  "Cutting" : {
    "dDom" : "<th>No</th><th>Part Name</th><th>Raw Material</th><th>Order Qty</th><th>Qty</th><th>Marker 's Size</th><th>Req Hrs</th><th>Cutting Start</th><th>Cutting End</th><th>Status</th></tr></thead>",
    "link" : "msp/loopForCutting"
  "Printing" : {
    "dDom" : "<th>No</th><th>Part Name</th><th>Order Qty</th><th>Qty</th><th>Colour Print</th><th>Type</th><th>No of Up</th><th>Req Hrs</th><th>Printing Start</th><th>Printing End</th><th>Status</th><th >Action</th></tr></thead>",
    "link" : "msp/loopForCutting"

and this is the php code:

// Display the data in the form i wanted
		$iloop = 1;
		foreach ($rResult->result_array() as $aRow) { 
       if($department == 'Printing') {
        $material = $aRow['material_part'];
        $qty      = $aRow['qty'];
        $demand   = $aRow['UPH'];
        $colprint = $aRow['colprint'];
        $noup     = $aRow['noup'];
        $reqhrs   = ((($colprint * $qty) / $demand) / $noup);
        $btn      = "<a class='btn'  data-mat = \"{$material}\" onclick=\"openPrintingLog(this, 'prnlog','{$iloop}', '{$idschedule}')\"></a>";
        $row[0]   = $btn;
        $row[1]   = $material;
        $row[2]   = $aRow['qty'];
        $row[3]   = $aRow['prnqty'];
        $row[4]   = $aRow['colprint'];
        $row[5]   = $aRow['coltype'];
        $row[6]   = $aRow['noup'];
        $row[7]   = number_format($reqhrs,2,'.','');
        $row[8]   = "<span class='editable' data-from='part' data-field='printingstart' data-id='{$aRow['idschedulepart']}'>{$aRow['printingstart']}</span>";
        $row[9]   = "<span class='editable' data-from='part' data-field='printingend'   data-id='{$aRow['idschedulepart']}'>{$aRow['printingend']}</span>";
        $row[10]  = $aRow['status'];
	   $row[11] = "<a class='btn btn-small' onclick='open_wrappers();'>Complete</a>"; //added by hyj
			$iloop = $iloop + 1;
			$output['aaData'][] = $row;

Thank in advance.

What I have tried:

I have searching for how to using colspan and rowspan,and found this page but don't know how it works.

Updated 21-Aug-17 3:47am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

colspan and rowspan DO NOT merge data.
They merge column and rows in HTML tables

That means they get rid of the boundary wall for the number of rows and/or columns specified.

If you wish to merge the data, you must create the data in the merged form.

For example, if text and a button were in separate columns next to one another, colspan='2' would expand the text to two columns and put the button in the NEXT column over. If you create the text and button, they must be in the same <td> (or <th>) to begin with, and if you need space, then you colspan that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100