We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

how to Integrate checkbox with dynamic value in specific grid column.

Hello,

can anyone have some ideas about how can i display checkbox in grid column with dynamic value.

Thanks.

3 Replies

GL Gowri Loganathan Syncfusion Team January 27, 2020 12:02 PM UTC

Hi Customer, 

Greetings from Syncfusion Support. 

QUERY: Display checkbox in the first column of grid with dynamic values 
 
From your query we understand that you need to have checkbox as one of the column of grid. This can be achieved by creating column with type as “checkbox”. Please check the below help documentation, 

Also if you have one of column in your data as Boolean type and if you need to render checkbox column with those Boolean data, you can use the property “displayAsCheckbox” set to true. 

Please check the below help documentation, 

Please check the below code snippet, 


<div class="cols-sample-area"> 
    <?php 
     
    $col1 = new EJ\Grid\Column(); 
    $col1->type('checkbox')->headerText("Column with type as checkbox")->width(70); 
    $col2 = new EJ\Grid\Column(); 
    $col2->field("Verified")->headerText("Boolean column displayed as checkbox")->displayAsCheckbox(true)->width(70); 
    $col3 = new EJ\Grid\Column(); 
    $col3->field("help_topic_id")->headerText("OrderID")->isPrimaryKey(true)->textAlign("right")->width(100); 
    $gridColumns = array($col1,$col2,$col3); 
    echo $grid -> dataSource($dataManager)->columns($gridColumns)->allowPaging(true)render(); 
    ?> 

</div> 

In the above sample, “Verified” column is Boolean column.  

If you need checkbox just to select rows, you can use column with type as “checkbox”. If you need to edit, save (i.e change) the values of checkbox, you can use displayAsCheckbox property with your Boolean  column.  
  
If your requirement is different from the above mentioned solutions, please explain your requirement in detail. Also share us the below details,  
  1. Complete grid rendering code
  2. Version details

If you have further queries, please get back to us. 

Regards, 
Gowri V L. 



IS Ishan Shah January 31, 2020 06:02 AM UTC

Hello, I have one idea, which is in the following code :

<?php 
    //Write the query
    $sql = "SELECT `name` FROM Students";

    //Run the query
    $query_resource = mysql_query($sql);

    //fetch the result
    while( $student = mysql_fetch_assoc($query_resource) ):
?>

    <span><?php echo $student['name']; ?></span>
    <input type="checkbox" name="student[]" value="<?php echo $student['name']; ?> /><br />

<?php endwhile; ?>


The example works these things to actually function properly:

You're using the Mysql server or SQL server and your student table must give records when querying on that table.


GL Gowri Loganathan Syncfusion Team February 3, 2020 09:18 AM UTC

Hi Ishan, 
 
Thanks for the update.  
 
Please get back to us if you need further assistance from us. 
 
Regards, 
Gowri V L. 


Loader.
Live Chat Icon For mobile
Up arrow icon