iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
I have a webgrid control on my webpage that shows 4 columns. The first column is a RowSelector and the others are simple Text columns. I want to know a way where when users type the characters, the row that starts with the character is highlighted or selected.
For example : Say my grid has one of the columns that has the name of the employees. Is there a way where when users type 'U', the cursor comes to the row with the employee Name starting with 'U' ?
This typically happens in a ListBox control, but I was wondering if webgrid supports such events.
Please suggest.
-Udayan
Hi Udayan,
For this problem, I've made my own sample that can be used as workaround for this matter. In my sample, I search the value in onkeydown client side event. I compared the keycode with cell's value of specific column. Then after I found the same value, I just simply select the row. I also attach my sample here. Hope this helps.
Regards,
Bernard
Thanks Bernard! This solution is great. I am marking it as the solution.
But I am struggling with a small issue here. When I am typing say 'a' twice, it checks the first row and then goes to the next row. I donot want to check the row unless I explicitly click and check the row. Is there a property that I need to set to make sure the rows are checked only when I click it?
Please let me know.
Thanks
Udayan
Unfortunately, there's no property to make sure the rows are checked when you click it. However, you can make validation to check if there's a selected row by using this code
if(WebGrid1.GetSelectedObject() != null)
Hope this helps.
Hi Bernard,
I was able to solve this problem with your help. I appreciate your inputs. The solution fails when the column starts with characters like '%' or '#' Since we are doing it on key-press event, when I hold shift key, this event gets fired.
Please let me know a work-around.
Sorry for the late responses. This problem can be solved if we using onkeypress event in some control but WebGrid doesn't have that event. From what I read, onkeypress event doesn't detect esc, ctrl, alt, and shift key. But still we can use OnKeyDown event and I've made work around that might be help you to solve this matter.
Here's the code:
function KeyDown(controlId, tblName, rowIndex, cellIndex) { var WebGrid1 = ISGetObject(controlId); var key; //parameter to search //escape shift key to trigger this event if(event.keyCode == 16) return false; //initial value var flag = false; key = String.fromCharCode(event.keyCode).toLowerCase(); if (!(parseInt(event.keyCode) > 64 && parseInt(event.keyCode) < 91)) { //check if shift key is being pressed or no if(event.shiftKey) { switch(key) { //you can add the special character here case '1': key = "!"; break; case '2': key = "@"; break; } } } //search loop for (var i = WebGrid1.GetSelectedObject().rowIndex + 1; i < WebGrid1.RootTable.GetRowsCount(); i++) { if (key == WebGrid1.RootTable.GetRow(i).GetCell(0).Text.toString().substring(0, 1).toLowerCase()) { WebGrid1.RootTable.GetRow(i).Select(); flag = true; break; } } if (flag == false) { for (var i = 0; i < WebGrid1.GetSelectedObject().rowIndex; i++) { if (key == WebGrid1.RootTable.GetRow(i).GetCell(0).Text.toString().substring(0, 1).toLowerCase()) { WebGrid1.RootTable.GetRow(i).Select(); flag = true; break; } } } return true; }
Regards,Bernard
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname