选取合适的dHtml Grid方案

目前网上主流的有四种方案:

1 dhtmlxGrid
http://www.scbr.com/docs/products/dhtmlxGrid/index.shtml
免费版可以填充表格,表格也非常漂亮。但是无法得到数据,或者将修改过的表格内容序列化成xml,只有专业版才可以。

2 activewidgets-grid 1.0.0
http://www.activewidgets.com/
功能非常强大,甚至可以分页,界面也有好看的皮肤。但1.0 同样无法取数据。2.0也不是免费的,

3 DHTMLGrid Ver0.92
http://dhtmlgrid.sourceforge.net/
功能及其简单,界面比较难看

4 os3grid 0.6
http://os3grid.sourceforge.net
功能还可以,不过界面简单。虽然架构不好,但是可以扩展,而且毕竟是LGPL的许可。

最终我还是选用os3grid来做工资录入界面.

创建界面的代码为:
    // Create an OS3Grid instance
    var g = new OS3Grid ();

    // Set the callback for modifications
    g.onchange = row_modified;

    g.set_size ( "400px", "200px" );
    
    // Grid Headers are the grid column names
    g.set_headers ( 'nick', 'name', 'email addr' );

    // If contents is bigger than container, Grid will automatically show scrollbars
    g.set_scrollbars ( true );

    // The grid will have a solid border (these are CSS attributes)
    g.set_border ( 1, "solid", "#cccccc" );

    // Now, we add some rows
    g.add_row ( "fsoft", "Fabio Rotondo", "fsoft (@) sourceforge (dot) net" );
    g.set_row_attr ( -1, 'magic', 'magic-fsoft' );
    g.set_row_attr ( -1, 'changed', 'NO' );

    g.add_row ( "nick", "Nick Fury", "nick (@) sourceforge (dot) net" );
    g.set_row_attr ( -1, 'magic', 'magic-nick' );
    g.set_row_attr ( -1, 'changed', 'NO' );

    g.add_row ( "john", "John JJ Jameson", "john (@) sourceforge (dot) net" );
    g.set_row_attr ( -1, 'magic', 'magic-john' );
    g.set_row_attr ( -1, 'changed', 'NO' );

    g.add_row ( "reds", "Mary Jane Watson", "mj (@) sourceforge (dot) net" );
    g.set_row_attr ( -1, 'magic', 'magic-mj' );
    g.set_row_attr ( -1, 'changed', 'NO' );

    g.add_row ( "white", "Barry White", "barryw (@) sourceforge (dot) net" );
    g.set_row_attr ( -1, 'magic', 'magic-barryw' );
    g.set_row_attr ( -1, 'changed', 'NO' );

    // Enable sortable rows
    g.set_sortable ( true );

    // Enable highlight of rows with the mouse
    g.set_highlight ( true );

    g.set_col_editable ( 1, "txt" );
    g.set_col_editable ( 2, "txt" );

    g.sort_on_edit = true;

    // Show the grid replacing the original HTML object with the "grid" ID.
    g.render ( 'grid' );

取得数据的代码,这是最关键的

     var l = g.length ();
     var t;
     var data, attrs;
     var s = "";
     var i, v;

     for ( t = 0; t < l; t ++ )
     {
      data = g.get_row ( t );
      alert(data[0]+data[1]+data[2]);

     }



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=667744


你可能感兴趣的:(html)