Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Oleg Timoshechkin on Nov 12, 2009 05:17
open dhtmlx forum
How to set value of a cell in a grid attached to a tag div a content tabbar from other window?

FOR THE Load USED THE FILE: "fofm_attach_add_placework_2.php", WHERE ELEMENT DIV FOR GRID CONTAINS:


<div id='grid_oborud' style="height: 100px; width: 500px"></div>






CREATE THE WINDOW:


function Windemo(id)
{
        var modWin = dhxWins.createWindow(id, 1, 1, 800, 500);
        modWin.setModal(true);
        modWin.center(true);
        modWin.setText("Создание нового рабочего места");
        var toolbar = modWin.attachToolbar();
        toolbar.setIconsPath("dhtmlxSuite/dhtmlxToolbar/samples/common/imgs/");
        toolbar.addButton("submit",0,"Сохранить","new.gif");
        toolbar.setItemToolTip("submit", "Сохранить");
        toolbar.attachEvent("onClick", function (id){if(id=="submit"){dhxWins.window("id1").close();});
        tabbar = modWin.attachTabbar();
        tabbar.setSkin("dhx_skyblue");
        tabbar.setImagePath("dhtmlxSuite/dhtmlxTabbar/codebase/imgs/");
        tabbar.addTab("a1", "Основная информация","150");
        tabbar.addTab("a2", "Организация труда","150");
        tabbar.addTab("a3", "Условия труда","110");
        tabbar.addTab("a4", "Льготы, компенсации, СИЗ","200");
        tabbar.setHrefMode("ajax-html");

INSERT FILES PHP IN TABBAR:

        tabbar.forceLoad("a1", "windows/placework/attach/fofm_attach_add_placework_1.php");
        tabbar.forceLoad("a2", "windows/placework/attach/fofm_attach_add_placework_2.php");
        tabbar.forceLoad("a3", "windows/placework/attach/fofm_attach_add_placework_3.php");
        tabbar.forceLoad("a4", "windows/placework/attach/fofm_attach_add_placework_4.php");
        tabbar.setTabActive("a1");
        tabbar.attachEvent("onTabContentLoaded", function(id_tab){if(id_tab=="a2"){grid_oborud();}});
        
    function grid_oborud()
    {
        
        function onButtonClick(menuitemId)
    {
        var rowId=dhxGrid.contextID.split("_")[0];
            var colInd=dhxGrid.contextID.split("_")[1];
            if (menuitemId=="add") {var newrowId = dhxGrid.uid(); dhxGrid.addRow(newrowId,"");}
            if (menuitemId=="del") {dhxGrid.deleteRow(rowId); if (rowId==0){dhxGrid.addRow("0","");}}
    }


INSERT GRID INTO OBJECT DIV:
        
        var dhxGrid = new dhtmlXGridObject('grid_oborud');
        dhxGrid.setImagePath("../../../dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
        dhxGrid.setHeader("Код,Наименование,Количество");
        dhxGrid.setInitWidths("50,300,100");
         dhxGrid.setColAlign("left,center,left");
        dhxGrid.setSkin("light");
        dhxGrid.setColSorting("str,int,int");
        dhxGrid.setColTypes("ro,ro,ed");
        dhxGrid.enableTooltips("false,false,false");
        dhxGrid.setAwaitedRowHeight("10px");

        dhxGrid.attachEvent("onRowDblClicked", function(rId,cInd){WinSprav_Others(rId,cInd)});

        var menu1 = new dhtmlXMenuObject();
        menu1.renderAsContextMenu();
        menu1.setIconsPath("../../../dhtmlxSuite/dhtmlxMenu/samples/common/imgs/");
        menu1.attachEvent("onClick",onButtonClick);
        menu1.addNewChild(menu1.topId, 0, "add", "Добавить", false, "open.gif");
        menu1.addNewChild(menu1.topId, 1, "del", "Удалить", false, "open.gif");

        dhxGrid.enableContextMenu(menu1);
        dhxGrid.init();
        dhxGrid.addRow("0","");

    }
}
    
DOUBLE CLICK OF THE MOUSE ON ROW GRID THE NEW WINDOW OPENS:
    
    function WinSprav_Others(rId,cInd)
    {
    var w1 = dhxWins.createWindow(id, 1, 1, 800, 500);
    w1.setText('select');
    var dhxLayout = w1.attachLayout("1C");                        
    dhxLayout.cells("a").hideHeader();
    w1.attachHTMLString(str);
    var str = '<a href="javascript:dhxGrid.cellById(rId,cInd).setValue("X");"> Set Value </a>';
    }

WHAT LINK ON THE CELL IN THE GRID OF THE PREVIOUS WINDOW WILL THE CORRECT?

dhxGrid.cellById(rId,cInd).setValue("X") - DOES NOT WORK.
Answer posted by Alex (support) on Nov 12, 2009 05:41

Hello,

To set value of a cell you can you setValue method:

gridObject.cells(rowId,cellIndex).setValue(VALUE);