jQuery UI Widgets Forums Grid Combobox and Grid

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 9 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Combobox and Grid #77859

    vincmeister
    Participant

    Hello,

    Sorry for the newbie question. I’m trying the Combobox and Grid Demo here
    I found a problem that the grid’s data, no filtered as the combobox value

    Here’s the code, please advise, thank you

    <script>
    		// prepare the data
    		var customerSource =
    		{
    			datatype: "json",
    			datafields: [
    			{ name: 'customer_code', type: 'int'},
    			{ name: 'customer_name', type: 'string'}
    			],
    			url: "../data/datacb.php",
    			async: false
    		};
    		var customerDA = new $.jqx.dataAdapter(customerSource);
    		$("#jqxcombobox").jqxComboBox(
    		{
    			width: 300,
    			height: 25,
    			source: customerDA,
    			
    			promptText: 'Select an Customer',
    			selectedIndex: -1,
    			displayMember: 'customer_name',
    			valueMember: 'customer_code'
    		});
    		$("#jqxcombobox").bind('select', function(event)
    		{
    			// get customer's ID.
    			var customer_code = event.args.item.value;
    			// prepare the data
    			var trans_detailSource =
    			{
    				datatype: "json",
    				datafields: [
    				{ name: 'customer_code', type: 'string', values: { source: customerDA.records,  name: 'customer_name' }},
    				{ name: 'item_code', type: 'string'},
    				{ name: 'quantity_in', type: 'string'},
    				{ name: 'enduser_code', type: 'string'},
    				{ name: 'enduser_name', type: 'string'}
    				],
    				type: 'POST',
    				data: {customer_code:customer_code},
    				url: "../data/datagr.php"
    			};
    			var dataAdapter = new $.jqx.dataAdapter(trans_detailSource);
    			$("#TransDetailGrid").jqxGrid({ 
    			source: dataAdapter,
    			width: 900,
    			columns: 
    			[
    				{datafield: "customer_code", text: "Customer", width: '30%'},
    				{datafield: "item_code", text: "Item", width: '10%'},
    				{datafield: "quantity_in", text: "Jumlah", width: '10%'},
    				{datafield: "enduser_code", text: "R", width: '25%'},
    				{datafield: "enduser_name", text: "R Name", width: '25%'}
    			]
    			});
    		}); 
        </script>
    
    <?php
     #Include the connect.php file
       include('../data/connect.php');
      #Connect to the database
      //connection String
    $mysqli = new mysqli($hostname, $username, $password, $database);
    	/* check connection */
    	if (mysqli_connect_errno()) {
    		printf("Connect failed: %s\n", mysqli_connect_error());
    		exit();
    	}
      // get data and store in a json array
        $query = "SELECT customer_code, customer_name FROM master_customer";
    	$result = $mysqli->prepare($query);
    	$result->execute();
    	
    	/* bind result variables */
    	$result->bind_result($customer_code, $customer_name);
    	/* fetch values */
    	while ($result -> fetch()) {
    	  $master_customer[] = array(
              'customer_code' => $customer_code,
              'customer_name' => $customer_name
          );
    }	
    echo json_encode($master_customer);
    	/* close statement */
    $result->close();
    	/* close connection */
    $mysqli->close();
    ?>
    
    <?php
    	#Include the connect.php file
    	include('../data/connect.php');
    // Connect to the database
    // connection String
    $mysqli = new mysqli($hostname, $username, $password, $database);
    /* check connection */
    if (mysqli_connect_errno())
    	{
    	printf("Connect failed: %s\n", mysqli_connect_error());
    	exit();
    	}
    // get data and store in a json array
    $query = "SELECT customer_code, item_code, quantity_in, enduser_code, enduser_name  FROM trans_in_detail where customer_code =?";
    $result = $mysqli->prepare($query);
    $result->bind_param('i', $_POST["customer_code"]);
    $result->execute();
    /* bind result variables */
    $result->bind_result($customer_code, $item_code, $quantity_in, $enduser_code, $enduser_name);
    /* fetch values */
    while ($result->fetch())
    {
    $trans_in_detail[] = array(
    'customer_code' => $customer_code,
    'item_code' => $item_code,
    'quantity_in' => $quantity_in,
    'enduser_code' => $enduser_code,
    'enduser_name' => $enduser_name
    );
    }
    echo json_encode($trans_in_detail);
    /* close statement */
    $result->close();
    /* close connection */
    $mysqli->close();
    ?>
    Combobox and Grid #77870

    Peter Stoev
    Keymaster

    Hi vincmeister,

    The client side seems to be like in our working demo. The server side is specific for your DB so you may not have data for a specific combobox value.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Combobox and Grid #77872

    vincmeister
    Participant

    hello Peter,
    Thanks for the reply.

    So what should I do? Sorry, i’m newbie. Just trying to adapt the demo to my need.
    Please advise, thank you

    Combobox and Grid #77873

    Peter Stoev
    Keymaster

    Hi vincmeister,

    Debug your PHP code, check your DB whether it has records for all IDs. It could be normal that it does not have for some IDs.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.