Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by rahul on Jul 01, 2009 02:24
open dhtmlx forum
subgrid

hi,

Do i need to only formate XML and set event ---> mygrid.setColTypes("sub_row_grid,ed,ed,ed,ed,ed,ed,ed,ed");

below is my coe and XML. Please make my code correct and plz plz help, its urgent.


-----------------------------------------------------------CODE--------------------------------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body onload="doInitGrid();">
<script>

function addRow()
{
var newId = (new Date()).valueOf()
mygrid.addRow(newId, "", mygrid.getRowsNum())
mygrid.selectRow(mygrid.getRowIndex(newId), false, false, true);
}
function removeRow()
{
var selId = mygrid.getSelectedId()
mygrid.deleteRow(selId);
}


var mygrid;

function doInitGrid() {
mygrid = new dhtmlXGridObject('mygrid_container');

mygrid.setImagePath("App_Data/imgs/");

mygrid.setColTypes("sub_row_grid,ed,ed,ed,ed,ed,ed,ed,ed");

mygrid.setHeader("s.no,book_name,auther,points,issue,copy,in/out,date");
mygrid.attachHeader('#rspan,#text_filter,#text_search,#rspan,#rspan,#rspan,#rspan,#rspan');
mygrid.attachFooter("total:{#strat_count},#cspan,Sum:{#start_multi_total}2:3,#cspan',[",",'text-align:right;',"]);


mygrid.setInitWidths("50,100,100,50,50,50,50,200");

mygrid.setSkin("light");
mygrid.enableMultiline(true);

mygrid.init();

mygrid.loadXML("grid.xml");

mygrid.setColSorting("int,str,str,int,int,int,int,int");

mygrid.splitAt(2);

mygrid.enableDragAndDrop(true);
//mygrid.groupBy(6);

}



</script>

<form id="form2" runat="server">

<%--<link rel="STYLESHEET" type="text/css" href="calendar.css"> --%>

<link rel="STYLESHEET" type="text/css" href="dhtmlxgrid.css">

<link rel="STYLESHEET" type="text/css" href="dhtmlxcombo.css">
<link href="dhtmlxtree.css" rel="stylesheet" type="text/css" />
    <script src="dhtmlxcombo.js"></script>
    <script src="dhtmlxcommon.js"></script>

<script src="codebase/dhtmlxgrid_filter.js" type="text/javascript"></script>

<script src="codebase/dhtmlxgrid_group.js" type="text/javascript"></script>

<script src="codebase/dhtmlxgrid_excell_sub_row.js"></script>
<script src="dhtmlxtreegrid.js"></script>

<script src="dhtmlxgrid.js"></script>

<script src="dhtmlxgridcell.js"></script>
    

<script src="codebase/dhtmlxgrid_splt.js" type="text/javascript"></script>
    
    <%--<script src="calendar.js"></script> --%>


<script>
tree.enableSmartXMLParsing(true); //false to disable
</script>

<div id="mygrid_container" style="width:550px;height:650px;"></div>
<input type="text" id="textobject" />
    
<button onclick="addRow()">Add Row</button>
<button onclick="removeRow()">Remove Row</button>

</form>
</body>
</html>


-----------------------------------------------------------XML--------------------------------------------------------------------------------------------


<?xml version="1.0" encoding="UTF-8"?>
<rows>
    <row id="1" type="sub_row_grid " open="1">
        <cell>-1500</cell>
        <cell>A Time to Kill</cell>
        <cell>John Grisham</cell>
        <cell>12.99</cell>
        <cell>1</cell>
        <cell>24</cell>
        <cell>0</cell>
        <cell>05/01/1998</cell>
<userdata name="drag">allow</userdata>
<row id="1">
<cell>hero</cell>
<cell>yes</cell>
</row>
    </row>
    <row id="2" type="sub_row_grid " open="1">
        <cell>1000</cell>
        <cell>Blood and Smoke</cell>
        <cell>Stephen King</cell>
        <cell>0</cell>
        <cell>1</cell>
        <cell>24</cell>
        <cell>0</cell>
        <cell>01/01/2000</cell>
<userdata name="drag">allow</userdata>
<row id="1">
<cell>hero</cell>
<cell>yes</cell>
</row>
    </row>
    <row id="3" selected="1">
        <cell>-200</cell>
        <cell>The Rainmaker</cell>
        <cell>John Grisham</cell>
        <cell>7.99</cell>
        <cell>0</cell>
        <cell>48</cell>
        <cell>0</cell>
        <cell>12/01/2001</cell>
    </row>
    <row id="4">
        <cell>350</cell>
        <cell>The Green Mile</cell>
        <cell>Stephen King</cell>
        <cell>11.10</cell>
        <cell>1</cell>
        <cell>24</cell>
        <cell>0</cell>
        <cell>01/01/1992</cell>
    </row>
    <row id="5">
        <cell>700</cell>
        <cell>Misery</cell>
        <cell>Stephen King</cell>
        <cell>7.70</cell>
        <cell>0</cell>
        <cell>na</cell>
        <cell>0</cell>
        <cell>01/01/2003</cell>
    </row>
    <row id="6">
        <cell>-1200</cell>
        <cell>The Dark Half</cell>
        <cell>Stephen King</cell>
        <cell>0</cell>
        <cell>0</cell>
        <cell>48</cell>
        <cell>0</cell>
        <cell>10/30/1999</cell>
    </row>
    <row id="7">
        <cell>1500</cell>
        <cell>The Partner</cell>
        <cell>John Grisham</cell>
        <cell>12.99</cell>
        <cell>1</cell>
        <cell>48</cell>
        <cell>1</cell>
        <cell>01/01/2005</cell>
    </row>
    <row id="8">
        <cell>500</cell>
        <cell>It</cell>
        <cell>Stephen King</cell>
        <cell>9.70</cell>
        <cell>0</cell>
        <cell>na</cell>
        <cell>0</cell>
        <cell>10/15/2001</cell>
    </row>
    <row id="9">
        <cell>400</cell>
        <cell>Cousin Bette</cell>
        <cell>Honore de Balzac</cell>
        <cell>0</cell>
        <cell>1</cell>
        <cell>1</cell>
        <cell>0</cell>
        <cell>12/01/1991</cell>
    </row>
    <row id="10">
        <cell>-100</cell>
        <cell>Boris Godunov</cell>
        <cell>Alexandr Pushkin</cell>
        <cell>7.15</cell>
        <cell>1</cell>
        <cell>1</cell>
        <cell>0</cell>
        <cell>01/01/1999</cell>
    </row>
    <row id="11">
        <cell>-150</cell>
        <cell>Alice in Wonderland</cell>
        <cell>Lewis Carroll</cell>
        <cell>4.15</cell>
        <cell>1</cell>
        <cell>1</cell>
        <cell>0</cell>
        <cell>01/01/1999</cell>
    </row>
<row id="12" type="sub_row_grid " open="1">
<cell>-1500</cell>
<cell>A Time to Kill</cell>
<cell>John Grisham</cell>
<cell>12.99</cell>
<cell>1</cell>
<cell>24</cell>
<cell>0</cell>
<cell>05/01/1998</cell>
<row id="12">
<cell>hero</cell>
<cell>yes</cell>
</row>
</row>
<row id="13" type="sub_row_grid " open="1">
<cell>1000</cell>
<cell>Blood and Smoke</cell>
<cell>Stephen King</cell>
<cell>0</cell>
<cell>1</cell>
<cell>24</cell>
<cell>0</cell>
<cell>01/01/2000</cell>
<row id="13">
<cell>hero</cell>
<cell>yes</cell>
</row>
</row>
<row id="14" selected="1">
<cell>-200</cell>
<cell>The Rainmaker</cell>
<cell>John Grisham</cell>
<cell>7.99</cell>
<cell>0</cell>
<cell>48</cell>
<cell>0</cell>
<cell>12/01/2001</cell>
</row>
<row id="15">
<cell>350</cell>
<cell>The Green Mile</cell>
<cell>Stephen King</cell>
<cell>11.10</cell>
<cell>1</cell>
<cell>24</cell>
<cell>0</cell>
<cell>01/01/1992</cell>
</row>
<row id="16">
<cell>700</cell>
<cell>Misery</cell>
<cell>Stephen King</cell>
<cell>7.70</cell>
<cell>0</cell>
<cell>na</cell>
<cell>0</cell>
<cell>01/01/2003</cell>
</row>
<row id="17">
<cell>-1200</cell>
<cell>The Dark Half</cell>
<cell>Stephen King</cell>
<cell>0</cell>
<cell>0</cell>
<cell>48</cell>
<cell>0</cell>
<cell>10/30/1999</cell>
</row>
<row id="18">
<cell>1500</cell>
<cell>The Partner</cell>
<cell>John Grisham</cell>
<cell>12.99</cell>
<cell>1</cell>
<cell>48</cell>
<cell>1</cell>
<cell>01/01/2005</cell>
</row>
<row id="19">
<cell>500</cell>
<cell>It</cell>
<cell>Stephen King</cell>
<cell>9.70</cell>
<cell>0</cell>
<cell>na</cell>
<cell>0</cell>
<cell>10/15/2001</cell>
</row>
<row id="20">
<cell>400</cell>
<cell>Cousin Bette</cell>
<cell>Honore de Balzac</cell>
<cell>0</cell>
<cell>1</cell>
<cell>1</cell>
<cell>0</cell>
<cell>12/01/1991</cell>
</row>
<row id="21">
<cell>-100</cell>
<cell>Boris Godunov</cell>
<cell>Alexandr Pushkin</cell>
<cell>7.15</cell>
<cell>1</cell>
<cell>1</cell>
<cell>0</cell>
<cell>01/01/1999</cell>
</row>
<row id="22">
<cell>-150</cell>
<cell>Alice in Wonderland</cell>
<cell>Lewis Carroll</cell>
<cell>4.15</cell>
<cell>1</cell>
<cell>1</cell>
<cell>0</cell>
<cell>01/01/1999</cell>
</row>
</rows>


:(
please help me
Answer posted on Jul 01, 2009 02:34
To use sub grid first cell's value should be path to the sub grid xml file. If you have pro version you can find sub grid example at the dhtmlxGrid package dhtmlxGrid\samples\extended_modes\pro_subgrids.html