Friday, 24 April 2015

Simple example of datatables

Today's post is about use of datatables. Lot of examples are available on Internet. This example is just to explore it little more and explains how to read data from xml and display using datatables.

<?php

$file_url='blog.xml';
$file_content = file_get_contents($file_url);
$xml_string_arr=simplexml_load_string($file_content);

//Optional: Start of code if you want to add some attribute to xml
//code to add unique_id attribute
/*foreach( $xml_string_arr->xpath("entry") as $r ) {
    $attrs = $r->attributes();   
    if(!$attrs['unique_id'])
        $r->addAttribute('unique_id', $r->id);
}
$xml_string_arr->asXML($file_url);*/
//End of code if you want to add some attribute to xml



$json = json_encode($xml_string_arr);
$arr_new = json_decode($json,TRUE);

$required_content_arr = $arr_new['entry'];

?>
<!DOCTYPE html>
<html>
<head>
    <title>Task3</title>
    <link rel="stylesheet" href="DataTables/media/css/jquery.dataTables.css">
    <script src="DataTables/media/js/jquery.js"></script>
    <script src="DataTables/media/js/jquery.dataTables.js"></script>
</head>

<body>
  <table id="example" class="display" cellspacing="0" width="100%">
  </table>
</body>

</html>
<script language="javascript"> 
    $(document).ready(function() {
        var oTable = $('#example').dataTable({
            data: <?php echo json_encode($required_content_arr); ?>,
            columns: [
                { data: 'id' },
                { data: 'name' },
                { data: 'url' },
                { data: 'height' },               
            ]
        });
       
   
    } );   
   
</script>



Thanks!!!!!!!!!! Enjoy Programming :)

Odoo 10: Close wizard and open standard form

Hi, Today we are going to learn how to open standard form after saving data in wizard. Let's say I have created an wizard to fill bas...