Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1325
Select row by primary key value
posted

Hello,

"selectRow " method right now accepts only row number. How can I find it if I know primary key value for that row? Basically, I want to select row by its primary key value.

Parents Reply
  • 1015
    Suggested Answer
    posted in reply to Kunal

    I have a checkbox selector and I'm selecting the items on the rowsRendered event. (igGrid, IgniteUI 13.1.20131.2143) This is how I'm doing it:

    rowsRendered: function (evt, ui)
    {
    	//Knockout ViewModel, but it could just be an array
    	var boundModel = viewModel.selectedItems;
    	var gridId = ui.owner.id();
    
    	//For each of my saved selected items
    	//select the checkbox on the grid
    	for (var i = 0; i < boundModel().length; i++)
    	{
    		//the item's primary key
    		var key = boundModel()[i].Id;
    		
    		for (var x = 0; x < ui.owner.rows().length; x++)
    		{
    			//the row contains the key on an attribute data-id="primarykey"			
    			var rowKey = ui.owner.rows()[x].getAttribute("data-id");
    			if (key == rowKey)
    			{
    				$('#' + gridId).igGridSelection('selectRow', x);
    			}
    		}
    	}
    }
    
Children
No Data