Solved

De-Select List item(s) via script

  • 31 October 2017
  • 2 replies
  • 1 view

Badge +8

Hi All

 

Does anybody have any code which could be used to de-select an item(s)  from a smartform list view

In the project I'm building a user will select an item or items from a list view but then I need to be able to delect those items if some conditions are not met.

 

I cant see any out of the box options in K2 to do this so wondering if some script could be used?

 

Any help much appreciated

 

Paul

icon

Best answer by Albarghouthy 31 October 2017, 11:31

View original

2 replies

Userlevel 5
Badge +16

Hi Paul,


 


The following script will de-select all the selected items:


 


 


 $(".grid-body-content-wrapper tbody tr").each(function(index)
{
$(this).attr('class', '');
})

Not sure if you looking for something more specific, if you have the list item ID and you want to de-select this specifc item, you can try the following:


 


$(".grid-body-content-wrapper tbody tr").each(function(index)
{
try
{
var itemType ;
itemType = JSON.parse($(this).find("td").eq(0).attr("data-options"));

if(itemType.value=="ListItemID")
{

$(this).attr('class', '');
}
}
catch(err)
{}
})

Hope that helps

Badge +8

Hi Mustafa

 

For what I'm trying to do the first piece of code you send works great :)

Thanks for the quick reply
Paul

Reply