Hi,
I have two listgrids that I have set up to drag records back and forth. When I drag a record from one list to the other I can’t get the dropped record to highlight automatically in the drop list. I have used listGrid.selectRecord(record) in the drop function. What am I doing wrong?
Regards
Martin
Hi Martin,
Selecting the dropped record is an automatic consequence of the built-in behavior for dragging between lists, see this example.
If you are unable to get it to work, please show the complete code you are using.
Here is my full code:
isc.ListGrid.create({
canDragRecordsOut:true,
canAcceptDroppedRecords:true,
autoDraw:false,
ID:"ListGrid5",
dataSource: "securityRolesAvailableByUser",
dataPageSize: 25,
autoFetchData: false,
showAllRecords: true,
fields:[
{name:"roleName", title:"Assigned Roles - drag to remove"}
],
rowClick : function (record){
var roleID = record.roleID;
selectAssignedRole(roleID);
},
selectionType:"single",
dragType:"AssignedRoles",
dropTypes:"AvailableRoles",
dragDataAction:"move",
drop: function(){
var listGrid = EventHandler.dragTarget;
var record = listGrid.selection.getSelectedRecord();
securityRolesAvailableByUser.addData(record);
securityRolesNotAvailableByUser.removeData(record);
var roleID = record.roleID;
var timeoutFunction = "selectListRow(" + roleID + ")";
var t1=setTimeout(timeoutFunction, 100);
//do the default drop code
//return true;
},
sortFieldNum: 0
})
Not quite your full code - selectListRow(), which contains the code in question, was not shown.
function selectListRow(roleID){
//go thru the entries on the ListGrid5 and select the one with the given role ID
//select the dragged role
ListGrid5.focus();
for(var i=0; i < ListGrid5.data.getLength(); i++){
var record = ListGrid5.data.get(i);
var posRoleID = record.roleID;
if(posRoleID == roleID){
ListGrid5.deselectAll();
ListGrid5.selectItem(i);
break;
}
}
}
Well, that explains it I think. There is no selectItem() API, on the grid, you probably want selectRecord. Note you should pass it the record, not “i”.