@@ -5,11 +5,8 @@ class Example_smartgrid extends CI_Controller {
5
5
6
6
public function index ()
7
7
{
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 ;
13
10
// SQl for grid
14
11
$ where = '' ;
15
12
$ where .= !empty ($ employee_name ) ? " AND employee_name LIKE '% $ employee_name%' " : "" ;
@@ -24,26 +21,28 @@ public function index()
24
21
"2 " =>"Female "
25
22
);
26
23
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
+
27
26
// Column settings
28
27
$ 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 " ),
37
36
);
38
37
39
38
// Config settings, optional
40
39
$ config = array ("page_size " => 5 ,
41
- "grid_name " => "sg_1 " ,
42
40
"toolbar_position " => 'both ' );
43
41
42
+ // Load the SmartGrid Library
43
+ $ this ->load ->library ('SmartGrid/Smartgrid ' );
44
44
// Set the grid
45
45
$ this ->smartgrid ->set_grid ($ sql , $ columns , $ config );
46
-
47
46
// Render the grid and assign to data array, so it can be print to on the view
48
47
$ data ['grid_html ' ] = $ this ->smartgrid ->render_grid ();
49
48
0 commit comments