views:

241

answers:

2

Hi to all. I'm trying to optimize a website. The flow is i tried to query a certain table and all of its data entry in a page(w/ toolbars), work fine. When i tried to edit the page the problem is when i click the checkbox button i have to wait 2-5sec just by clicking it. I limit the viewing of entry to 5 only but the response on checkbox doesn't change. The tables have 100 entries in them.

function checkAccess(celDiv,id)
{
    var celValue = $(celDiv).html();

    if (celValue==1) $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' checked disabled>")
    else $(celDiv).html("<input type='checkbox' value='"+$(celDiv).html()+"' disabled>") 


    $(celDiv).click
    (
      function()
     {
      $('input',this).each(
        function(){

        tr_idx = $('#detFlex1 tbody tr').index($(this).parent().parent().parent()); 
        td_idx = $('#detFlex1 tbody tr:eq('+tr_idx+') td').index($(this).parent().parent());
        td_last = 13;
       for(var td=td_idx+1; td<=td_last;td++)
       {
        if ($(this).attr('checked') == true) 
        {
           df[0].rows[tr_idx].cell[td_idx] = 1;//index[1] = Full Access
         if (td_idx==3) 
          {
           df[0].rows[tr_idx].cell[td] = 1;
          }  
           df[0].rows[tr_idx].cell[2] = 1;
         if (td_idx > 3)
          {
           df[0].rows[tr_idx].cell[2] = 1;
          }      
        }
        else 
        {   
           df[0].rows[tr_idx].cell[td_idx] = 0;//index[0] = With Access
         if (td_idx==2) 
          {
           df[0].rows[tr_idx].cell[td] = 0;
          }
         else if (td_idx==3) 
          {       
           df[0].rows[tr_idx].cell[td] = 0;      
          }       
         if (td_idx > 3)
          {
           df[0].rows[tr_idx].cell[3] = 0;
          }
        }
       }
        $('#detFlex1').flexAddData(df[0]);
        $('.toolbar a[title=Edit Item]').trigger('click');
        }); 
     }
    );
}

I've thought that the problem is this above code. Could anyone help me simplify this code.?

A: 
Dean
A: 

Hi Dean,

Would you tell me, what exactly you want to achieve with checkAccess() function? Maybe we can start with that, and I can help you with optimized algorithm to achieve that.

Thanks.

Donny Kurnia