I don't see any jQuery in your example.
If I understand correctly, all you want to do upon clicking on a link/button is to call a function and give it an array, then edit your grid from that.
html:
<button>Edit item</button>
javascript:
function editGrid(array){
array.forEach(function(item){
alert(item);
});
// Edit your grid
}
$(function(){
$("button").click(function(){
editGrid(['categoryName1', 'categoryName2']);
});
});
Jsfiddle DEMO
Let me know if that helps.
Edit:
You could call the editGrid function with different parameters based on which button is clicked.
View my updated Jsfiddle DEMO.
$("#button1").click(function(){
editGrid(['categoryName1', 'categoryName2']);
});
$("#button2").click(function(){
editGrid(['categoryName3', 'categoryName4']);
});