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.

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.




<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:

Thank you.

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

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.

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.

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

Hi,

Thanks for providing us further details.

We will look into it soon.

Thank you.

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.

Hi Henry,

Thanks for your information, it solved my problem.

Best Regards,
Viann