Sign In  Sign Up Live-Chat

how to get cursor position in GridWeb when page number changed by JavaScript

Last post 08-05-2008, 5:28 AM by pc66smile. 8 replies.
Sort Posts: Previous Next
  •  07-30-2008, 6:16 AM 137501

    how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,
    I wrote a JavaScript to detect the cursor position when user click GridWeb,
    it was success in first page, but when the page changed,
    it cannot detect the cursor position any more.
    Please tell me how to get the position when page changed in JavaScript.
     
  •  07-30-2008, 7:22 AM 137510 in reply to 137501

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,

    Thanks for considering Aspose.

    Do you want to get the selected cell on the client side. And what do you mean by page changed, do you use paging or you navigate to next sheet. I think you can utilize Aspose.Grid.Web's some client side (javascript) functions / events for your task.

    Following is my testing code which works fine whether you change the page in paging or you navigate to other sheet. I utilized and handle onSelectedCell client event.

    Html source view of the webpage.

    <HEAD>
     <script language="javascript">
     <!--
     // Client side event handlers
     function onCellSelected(cell)
     {
      
      alert(cell.id);
      
     }
     
     -->
      </script>
     
     </HEAD>

     

    <agw:Gridweb id="GridWeb1" runat="server" PageSize="20" EnablePaging="True" .............OnCellSelectedClientFunction="onCellSelected">

     

    To get further ref, which client side events and functions GridWeb offers plus how can you utilize GridWeb's client side fucntion and events in scripting, please check the source code of the following:

    http://www.aspose.com/demos/aspose.grid/description/scripting/clientsideevents.htm

    http://www.aspose.com/demos/aspose.grid/description/scripting/clientsidefunctions.htm

     

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  07-30-2008, 10:24 PM 137656 in reply to 137510

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,
    Thanks for your answer.
    It's good information to me, but it still cannot resolve my problem.
    By "the page changed" I mean the paging changed.
    My program doesn't work when the pageindex was changed from page 1 to page 2,3,...
    I cannot get any information from GridWeb cell by Javascription.
    But when I return the pageindex to 1, it work again.

    I list my program code in below, maybe it could helpful.
    Server Side C# in VS2003
    GridWeb1.Attributes.Add("onclick", "GridWeb1.updateData(); GridWeb1.submit(); g1Selected('GridWeb1',16); grid1click();");

    Clinet Side BLOCKED SCRIPT
    function g1Selected(gridnm,gcolcnt) { 
     var rcnt=eval(document.forms[0].tbG1NRec.value);
     for (i=0; i<gcolcnt; i++) {
      document.getElementById(gridnm+'_'+i.toString()+'#'+rcnt.toString()).style.backgroundColor='white';
     }
     if(event.srcElement.id.search(/GridWeb1_/i)>=0) {
      var ipos = event.srcElement.id.search(/#/i);
      if(ipos>=0) {
       var recNo = event.srcElement.id.substr(ipos+1,5);
       for (i=0; i<gcolcnt;i++) {
        document.getElementById(gridnm+'_'+i.toString()+'#'+recNo.toString()).style.backgroundColor='skyblue';
       }
      }
     }
    }

    variable rcnt is the cursor position last time.
    variable recNo is the current cursor position.
    grid1click() is the function save the virable recNo to Server Obj tbG1NRec.

    best regards

     
  •  07-31-2008, 10:30 PM 137859 in reply to 137510

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi Amjad,

      Why the paging changed then the javascript error "Object required" occur??
      Could you tell me how to do that the script will be execute normally in the page 2,3,...?
      The GridWeb version is 1.7.4.0

      Thanks a lot.
     

     
  •  08-01-2008, 12:42 AM 137865 in reply to 137859

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,

    Since you are using older version of the control. Could you try our lastest version: http://www.aspose.com/community/files/53/visual-components/aspose.grid/entry126616.aspx

    Thank you.

     


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  08-01-2008, 4:19 AM 137906 in reply to 137865

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi Amjad,

      Thanks for your answer.
      I have been tried the lastest version GridWeb 2.0.0.1001, but the problem still in.
      It cannot find the page 2 object "GridWeb1_0#10" when the pagesize sets 10.
      When I rightclick mouse to view html source in page 1,
      I can found page 1 object "GridWeb1_0#0" ~ "GridWeb1_0#9",
      but if I using paging to changed the page to 2,
      I still just found page 1 object "GridWeb1_0#0" ~ "GridWeb1_0#9"....
     
      I hope you can understand my description and problem,
      please tell me how to resolve it, I extremely need your help.
     
      Thank you.
     
    Best Regards,
    Viann Tsai

     
  •  08-01-2008, 4:42 AM 137907 in reply to 137906

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,

    Thanks for providing us further details.

    We will look into it soon.

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
  •  08-04-2008, 2:40 AM 138166 in reply to 137906

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi,

          I am not very clear about your need, but, there's one thing you should pay attention to. The cell's id, for an example GridWeb1_a#b, where a is the real column number and b is the real row number int the work sheet. That means when you change to page 2, you will not find the GridWeb1_0#0. The cell's id will start with GridWeb_0#10.

       Wish this information helps. Thank you.

     


    Henry Xu
    Developer
    Aspose Nanjing Team
    About Us
    Contact Us
     
  •  08-05-2008, 5:28 AM 138358 in reply to 138166

    Re: how to get cursor position in GridWeb when page number changed by JavaScript

    Hi Henry,

         Thanks for your information, it solved my problem.

    Best Regards,
    Viann

     
View as RSS news feed in XML