@@ -5,11 +5,8 @@ class Example_smartgrid extends CI_Controller {
55
66 public function index ()
77 {
8- $ employee_name = trim ($ this ->input ->get_post ('employee_name ' , TRUE ));
9-
10- // Load the SmartGrid Library
11- $ this ->load ->library ('SmartGrid/Smartgrid ' );
12-
8+ $ employee_name = $ this ->input ->post_get ('employee_name ' , TRUE );
9+ $ data ['employee_name ' ] = $ employee_name ;
1310 // SQl for grid
1411 $ where = '' ;
1512 $ where .= !empty ($ employee_name ) ? " AND employee_name LIKE '% $ employee_name%' " : "" ;
@@ -24,26 +21,28 @@ public function index()
2421 "2 " =>"Female "
2522 );
2623
24+ $ buttons_html = '<div class="btn-group" role="group" aria-label=""><button type="button" class="btn btn-default btn-xs" value="{field_name}">View</button><button type="button" class="btn btn-success btn-xs" value="{field_name}">Edit</button> <button type="button" class="btn btn-danger btn-xs" value="{field_name}">Delete</button></div> ' ;
25+
2726 // Column settings
2827 $ columns = array (
29- "employee_id " =>array ("header " =>"Employee ID " , "type " =>"label " , "align " =>"left " , "width " =>"100px " ),
30- "employee_name " =>array ("header " =>"Employee Name " , "type " =>"label " , "align " =>"left " , "width " =>"150px " ),
31- "employee_dob " =>array ("header " =>"Date of Birth " , "type " =>"date " , "align " =>"center " , "width " =>"150px " , "date_format " =>"Y-m-d " , "date_format_from " =>"Y-m-d H:i:s " ),
32- "employee_join_date " =>array ("header " =>"Join Date " , "type " =>"relativedate " , "align " =>"left " , "width " =>"150px " ),
33- "employee_gender " =>array ("header " =>"Gender " , "type " =>"enum " , "source " =>$ gender_list , "align " =>"center " , "width " =>"100px " ),
34- "employee_salary " =>array ("header " =>"Salary " , "type " =>"money " , "sign " =>"$ " , "align " =>"right " , "width " =>"100px " ),
35- "performance_index " =>array ("header " =>"Performance " , "type " =>"progressbar " , "align " =>"center " , "width " =>"100px " ),
36- // "employee_img_url"=>array("header "=>"Image ", "type "=>"image ", "align "=>"center" , "width "=>"50px ", "image_width "=>"50px "),
28+ "employee_id " =>array ("type " =>"label " , "header " =>"Employee ID " , "align " =>"left " , "width " =>"100px " ),
29+ "employee_name " =>array ("type " =>"label " , "header " =>"Employee Name " , "align " =>"left " , "width " =>"" ),
30+ "employee_dob " =>array ("type " => " date " , " header " =>"Date of Birth " , "align " =>"center " , "header_align " =>"center " , "width " =>"150px " , "date_format " =>"Y-m-d " , "date_format_from " =>"Y-m-d H:i:s " ),
31+ "employee_join_date " =>array ("type " =>"relativedate " , "header " =>"Join Date " , "align " =>"left " , "width " =>"100px " ),
32+ "employee_gender " =>array ("type " =>"enum " , "header " =>"Gender " , "source " =>$ gender_list , "align " =>"center " , "width " =>"80px " ),
33+ "employee_salary " =>array ("type " =>"money " , "header " =>"Salary " , "sign " =>"$ " , "align " =>"right " , "width " =>"100px " ),
34+ "performance_index " =>array ("type " =>"progressbar " , "header " =>"Performance " , "align " =>"center " , "width " =>"150px " , " style " => " progress-bar-info " ),
35+ "employee_img_url " =>array ("type " =>"custom " , "header " =>"Buttons " , "field_data " =>$ buttons_html , "align " =>"center " , "width " =>"130px " ),
3736 );
3837
3938 // Config settings, optional
4039 $ config = array ("page_size " => 5 ,
41- "grid_name " => "sg_1 " ,
4240 "toolbar_position " => 'both ' );
4341
42+ // Load the SmartGrid Library
43+ $ this ->load ->library ('SmartGrid/Smartgrid ' );
4444 // Set the grid
4545 $ this ->smartgrid ->set_grid ($ sql , $ columns , $ config );
46-
4746 // Render the grid and assign to data array, so it can be print to on the view
4847 $ data ['grid_html ' ] = $ this ->smartgrid ->render_grid ();
4948
0 commit comments