Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
setSelection function does not work in the next row click
14/09/2009
08:56
Avatar
marcosvitali
Member
Members
Forum Posts: 4
Member Since:
14/09/2009
sp_UserOfflineSmall Offline

Hi Tony,

I am from Argentina sory for my english ๐Ÿ˜€

I use jqGrid 3.5 and jQuery 1.3.2

The setSelection function does not work. 

The problem is if you use "setSelection" function the next click on the row fails because "tr#" + X doesnt exists

Steps:

1) Load any jqgrid

2) jQuery("#Table1").setSelection(1);

3) I click a row

4) I have an error in the "setSelection : function" in "grid.base.js"

Line:

$("tr#"+$t.p.selrow.replace(".", "\\\\."),$t.grid.bDiv).removeClass("ui-state-highlight").attr("aria-selected","false");

My example code is:
function CreateGrid() 
{
jQuery("#Table1").jqGrid({
   datatype: "local",
   colNames:['Nombre','Direccion', 'Telefono', 'Distancia'],
   colModel:[
       {name:'Nombre',index:'Nombre', width:130},
       {name:'Direccion',index:'Direccion', width:130},
    {name:'Telefono',index:'Telefono', width:120},
    {name:'Distancia',index:'Distancia', width:100},    
   ],
   pager: jQuery('#Table1Div1'),
   rowNum:5,
   rowList:[10,20,30],
   caption: "Datos",
success: termino
});
var mydata = [
{id:"1",Nombre:"Marcos1",Direccion:"Lavalle 100",Telefono:"2322-3232",Distancia:"4000"},
{id:"2",Nombre:"Marcos2",Direccion:"Lavalle 100",Telefono:"2322-3232",Distancia:"4000"},
{id:"3",Nombre:"Marcos3",Direccion:"Lavalle 100",Telefono:"2322-3232",Distancia:"4000"},
{id:"4",Nombre:"Marcos4",Direccion:"Lavalle 100",Telefono:"2322-3232",Distancia:"4000"},
{id:"5",Nombre:"Marcos5",Direccion:"Lavalle 100",Telefono:"2322-3232",Distancia:"4000"}
];
for(var i=0;i<=mydata.length;i++)
jQuery("#Table1").addRowData(i+1,mydata[i]);
jQuery("#Table1").setSelection(1);
}
Thank's in advance Marcos
14/09/2009
22:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello

Correct first this error and try

   colModel:[

       {name:'Nombre',index:'Nombre', width:130},
       {name:'Direccion',index:'Direccion', width:130},
    {name:'Telefono',index:'Telefono', width:120},
    {name:'Distancia',index:'Distancia', width:100},<---- Error comma
   ],

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

15/09/2009
06:32
Avatar
marcosvitali
Member
Members
Forum Posts: 4
Member Since:
14/09/2009
sp_UserOfflineSmall Offline

Tony thank's for your answer but the same problem happens. ๐Ÿ™

The grid works perfect only I have a problems when use the method "setSelection" in any grid (JSON, XML, LOCAL with array) always an exepetion happens when I click in the row after use "setSelection", in all navigators Explorer, chrome, firefox.

To reproduce this error you can follow this steps:

1) Use setSelection method in any grid

2) After click in any row in the grid

3) An exception happens ๐Ÿ™

I love this grid ๐Ÿ˜€ but i need to select the first row in the grid when my application started..

Thank's a lot.

Marcos.

15/09/2009
09:02
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

2) jQuery(”#Table1″).setSelection(1);

setSelection takes a rowID, not a row index. If the ID you pass in is not the ID of an existing row, you will get this error next time you click on a row, as you describe.

It looks like it would be a good idea for the grid to check that the ID is valid - but you still need to fix your code if you want setSelection to do anything...

Mark

15/09/2009
10:32
Avatar
marcosvitali
Member
Members
Forum Posts: 4
Member Since:
14/09/2009
sp_UserOfflineSmall Offline

I am using the correct RowID (I think so)

For example this code does not work, I will get that error next time you click on a row.

Please, help me. What is my mistake? in this JSON ROW {id:"1",FirstName:"Mark",LastName:"Wise"} is this  id:"1" the rowID ??

The row is selected correctly, the problem is when I click on another row in te grid.

Thank you

<script type="text/javascript">    

$(document).ready(function(){

        CreateGrid();    

});

function CreateGrid() 

{

jQuery("#Table1").jqGrid({

   datatype: "local",

   colNames:['FirstName','LastName'],

   colModel:[

       {name:'FirstName',index:'FirstName', width:130},

       {name:'LastName',index:'LastName', width:130}    

   ],

   pager: jQuery('#Table1Div1'),

   rowNum:2,

   rowList:[10,20,30],

   caption: "Data",

sortname: 'FirstName',

     viewrecords: true

});

var mydata = [

{id:"1",FirstName:"Mark",LastName:"Wise"},

{id:"2",FirstName:"Jhon",LastName:"Harris"}

];

for(var i=0;i<=mydata.length;i++)

jQuery("#Table1").addRowData(i+1,mydata[i]);

jQuery("#Table1").setSelection(2);

}        

</script>

15/09/2009
11:46
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

I see. Sorry, now I see the problem ๐Ÿ™‚

First, note that the "id" in your data is ignored. The first parameter to addRowData determines the id.

But thats not the problem, because they are the same thing (i+1 == mydata[i].id).

The problem is that rowid's are strings. addRowData correctly converts an integer to a string before using it as an id, but setSelection does not.

I think it will work if you use

jQuery(”#Table1″).setSelection("2");

or

jQuery(”#Table1″).setSelection(2+"");

Mark

15/09/2009
11:46
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

I see. Sorry, now I see the problem ๐Ÿ™‚

First, note that the "id" in your data is ignored. The first parameter to addRowData determines the id.

But thats not the problem, because they are the same thing (i+1 == mydata[i].id).

The problem is that rowid's are strings. addRowData correctly converts an integer to a string before using it as an id, but setSelection does not.

I think it will work if you use

 

jQuery(รขโ‚ฌย#Table1รขโ‚ฌยณ).setSelection("2");

or

 

jQuery(รขโ‚ฌย#Table1รขโ‚ฌยณ).setSelection(2+"");

Mark

15/09/2009
12:49
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Thanks marcosvitali,

Thanks Mark,

The correction is in GitHub.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

16/09/2009
07:00
Avatar
marcosvitali
Member
Members
Forum Posts: 4
Member Since:
14/09/2009
sp_UserOfflineSmall Offline

 Thank you Tony and Mark!!!

The problem is solved now ๐Ÿ™‚ ๐Ÿ™‚

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
81 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information