K2 SmartForms Custom Control with DataSource

  • 5 October 2017
  • 1 reply
  • 30 views

I have a custom control that is linked to a smart object as a datasource.

 

On the control i have implemented the OnClick event and want to get the record that was clicked on using the linked smartobject fields. When i show one of the values of the smartobject in a message box it seems like the current row of the smartobject is empty.

 

How do i change the selected row in the smartobject in code?


1 reply

I have added the following javascript code to select the current row:

 

setSelected: function () {

var val = this.options.value;
var options = this.options;
var data = this.options.data;

$(options).removeClass("selected");

for (var k = 0; k < data.length; k++) {
var optionVal = data.text;
if (val == optionVal) {
$(data).addClass("selected");
break;
}
}
}

Hopefully i am moving in the right direction... not sure if what i am doing is 100% correct... would someone be able to help?

Reply