Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Velmurugant on Oct 14, 2009 05:33
open dhtmlx forum
how to apply empty validation multiple cells in a Row in TreeGrid?

Hi,
I am using TreeGrid in my application. I am adding new row with 4 cells. By using

myDataProcessor.setVerificator(1, not_empty);
It validates only the second cell in a row. but i want to validate 3 cells. how to do that?

Herewith i have attached my code


menu = new dhtmlXMenuObject(null,"standard");
     menu.setImagePath("themes/General/css/dhtmlxMenu/imgs/");
     menu.setIconsPath("themes/General/css/dhtmlxTree/images/");
     menu.renderAsContextMenu();
     menu.setOpenMode("web");
     menu.attachEvent("onClick",onButtonClick);
     var fileName=ContextMenushortPath+"_roleActions.xml";
     menu.loadXML(fileName);

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
     tree.setImagePath("themes/General/css/imgs/csh_bluefolders/");
     var filePath=GenerateXMLforAdminPath+"&Action=GenerateCategoryXML&Id=0";
     //alert(filePath);
     tree.loadXML(filePath,function(){

//init grid and set its parameters (this part as always)
     mygrid1 = new dhtmlXGridObject('gridbox1');
     mygrid1.setImagePath("themes/General/css/dhtmlxGrid/imgs/");
     var flds = "Role Name, Role Code, Category, Status";
        mygrid1.setHeader(flds);
        mygrid1.attachHeader("#text_filter,#text_filter,#select_filter,#select_filter");
        mygrid1.setInitWidths("390,200,300,220");
        mygrid1.setColAlign("left,left,left,left");
        mygrid1.setColTypes("tree,ed,stree,co");
        mygrid1.setSubTree(tree,2,0);
        mygrid1.setFiltrationLevel(-2);
        mygrid1.enableContextMenu(menu);
                        
        mygrid1.getCombo(3).put('Active',"Active");
mygrid1.getCombo(3).put('De-activated',"De-activated");    


//mygrid1.enableValidation(true);
//mygrid1.setColValidators("NotEmpty");

        mygrid1.setColumnIds("roleName,roleCode, category, Status");
        mygrid1.setSkin("gray");
        mygrid1.setColSorting("str,str,str,str,str")
        mygrid1.init();
        
         dhtmlxEvent(mygrid1.entBox,"contextmenu",function(e)
{
(e||event).cancelBubble = true
return false;
});

mygrid1.attachEvent("onBeforeContextMenu",function(itemId)
        {                                             
            if(document.getElementById('Add').value=="1")
            {
             menu.showItem('sibling');
             menu.showItem('child');
            
            }
            else
            {
              menu.hideItem('sibling');
             menu.hideItem('child');
             }
                      
              return true;
        });



mygrid1.attachEvent("onRightClick",function(itemId)
{        
         mygrid1.selectRowById(itemId);
         return true;

        });
        
        
        
                
    /*    var time1=document.getElementById('time').value;
     var xmlfile="Roles_"+time1+".xml";
     var filename=UploadShortPath + xmlfile;
     */
     function not_empty(value, id, ind)
{
// alert("value==>"+value+"\n id==>"+id+"ind==>"+ind);
if (value == ""){
alert(id);
alert(ind);
mygrid1.setCellTextStyle(id, ind, "background-color:#FF9966;");

}
return value != "";
}




     var newURL=currentPage+"&mode=saveRoles";
     myDataProcessor = new dataProcessor(newURL);
//lock feed url;
// myDataProcessor.setTransactionMode("POST", true);
//set mode as send-all-by-post;
myDataProcessor.setUpdateMode("on");
myDataProcessor.enableDataNames(true);
myDataProcessor.setVerificator(1, not_empty);




myDataProcessor.defineAction("success",my_action);

myDataProcessor.attachEvent("onRowMark", function(id)
{
alert(id);
/* var cell1value=mygrid1.cells(id,0).getValue();
alert(cell1value);
var cell2value=mygrid1.cells(id,1).getValue();
alert(cell2value);
var cell3value=mygrid1.cells(id,2).getValue();
alert(cell3value);
var cell4value=mygrid1.cells(id,3).getValue();
alert(cell4value); */

if (this.is_invalid(id) == "invalid")
return false;
return true;
});


         
     myDataProcessor.init(mygrid1);
    
    

     if(document.getElementById('View').value=="1")
{
var filePath=GenerateXMLforAdminPath+"&Action=GenerateRolesXML&Id=0";
mygrid1.loadXML(filePath,function(){
    
            mygrid1.forEachRow(function(id){
            //alert(id);
            if (mygrid1.cellById(id,3).getValue()=="Active") mygrid1.setCellTextStyle(id,3,"background-color: #a8ec90");
            else if (mygrid1.cellById(id,3).getValue()=="De-activated") mygrid1.setCellTextStyle(id,3,"background-color: #f6a1a5");
            });
            });
        }
        
        function my_action(node){
         if(node.getAttribute("type")=='success')
         {
         document.getElementById('statusmsg').innerHTML="<font color='green' size='2'>Operation successfull</font>";
        
         }
// alert(node.firstChild.data); // Details
return false;
}
    
    
    
     });
    
     function AddNewRow()
     {
     //alert(mygrid1.getRowsNum());
          var autoid=document.getElementById('nextRoleID').value;
          // var del="<a href='#' onclick='RemoveIssueType("+autoid+");'>Delete</a>";
     //var newValue="New Issue Type"+autoid+",New Issue Code"+autoid+",Active,"+del;
     // var newValue=" , ,Active,"+del;
     var newValue=" , , ,Active";
    
    
         //var WhereToAdd=mygrid1.getRowId(0);
         var WhereToAdd=0;
        
         // alert(WhereToAdd);
        
         mygrid1.addRow(autoid,newValue,WhereToAdd);
        
         mygrid1.setRowTextStyle(autoid,'border:1px solid #000000 ;');
        
         //mygrid1.setSelectedRow(autoid);
        
         document.getElementById('nextRoleID').value=parseInt(autoid)+1;
     }
    
    
     function onButtonClick(menuitemId,type)
        {
var id = mygrid1.contextID;
alert("ID===>"+id + "\n menuid =" + menuitemId + "\n type= " +type);
     }     
Answer posted by Stanislav (support) on Oct 14, 2009 09:05
You can use the setVerificator command few times

myDataProcessor.setVerificator(0 not_empty);
myDataProcessor.setVerificator(1, not_empty);
myDataProcessor.setVerificator(2, not_empty);
Answer posted by velmurugant on Oct 14, 2009 21:57
Thanks. It works well