KrishnaTejaK
Hi,
I have an issue and stuck with it for quite sometime now. Can someone please guide me. I need to bind a onclick event to an anchor element dynamically, I checked the examples that Giuseppe's pointed out but still no luck. Let's say I have my html code like :
<td id="msg" class="revSubject highlight" style="text-align:left;" nowrap="">
<a href="#" data-source="lightstreamer" data-field="click" data-update="onclick">
<span><div data-source="lightstreamer" data-field="msg"></div></span>
</a>
</td>
In my js code I did set node types as well :
grid.setNodeTypes(["div","tr","a"]);
From my java adapter I'm send the click field :
map.put("click", "getCCSInboxMsgBody(109539,0,"SysTrdInbox&quo t :Smile_Ad: ;return false;");
but still the event is not getting attached to the <a> element, I'm using DynaGrid with ADD command.
Giuseppe Corti
Hi Krishna Teja K,
The snippet of code you attached seems correct to me and the onclick should be actually updated.
Could you please try to trace if indeed your page receives the update with the click field? You could add a listener to your subscription, something like this:
dynaGrid.addListener({
onVisualUpdate: function(key,info,domNode) {
if (info == null) {
return;
}
info.forEachChangedField(tracefieldvalue);
}
})
Regards,
Giuseppe
KrishnaTejaK
Hi Giuseppe,
Thanks for the quick reply, yes you are correct the "click" field is not coming up even though I've added it to the java smart update arg map.
Giuseppe Corti
Hi Krishna Teja K,
Ok, so we need to understand why your client don't receive the "click" field as expected.
Please could you post here the code lines the client use to subscribe?
Are you able to access the server log? In that case we could also take advantage of particular log settings.
Regards,
Giuseppe
KrishnaTejaK
I just added a debugger and could see that the click field is present in "info.jJw" but not in "info.GVV", can you please explain what's happening here:
I don't see the field even in this function:
info.forEachChangedField(...)
KrishnaTejaK
Here's my client subscription code:
function linkToLS_Signal(lsTable,user_id,trdPlanStr,trdPlanSigType) {
console.log("In linkToLS_Signal");
require(["LightstreamerClient","Subscription","DynaGrid"],function(LightstreamerClient, Subscription, DynaGrid) {
var client = new LightstreamerClient("https://push.finodex.com","TEST");
client.connectionSharing.enableSharing("FdxShare","ATTACH","CREATE");
client.connect();
var grid = new DynaGrid(lsTable, true);
grid.setNodeTypes(["div","tr","a"]);
grid.setAutoCleanBehavior(true,false);
grid.addListener({
onVisualUpdate: function(key, info, domNode) {
if (info == null) {
return;
}
var myField;
info.forEachChangedField(function (field, value) {
myField = field;
info.setCellAttribute(myField, greenColor, null,"backgroundColor");
info.setCellAttribute(myField, hotTxtCol, null,"color");
});
}
});
var subsList = ['trsignal_'+user_id+'_'+trdPlanStr+'_'+trdPlanSigType];
var fieldsList = ['command', 'key', 'date', 'time', 'channel', 'msg', 'msgid'];
subscription = new Subscription("COMMAND", subsList, fieldsList);
//subscription.setRequestedSnapshot("no");
subscription.addListener(grid);
client.subscribe(subscription);
});
}
Giuseppe Corti
Hi Krishna Teja K,
You need to add 'click' in the fieldsList.
Regards,
Giuseppe
KrishnaTejaK
Thanks a lot, I overlooked it!
KrishnaTejaK
Giuseppe, we have another requirement in our project where we need to clear the messages(rows) from the table which are currently pushed already let's say when user changes the filter or clicks a button. Right now even though the screen is refreshed the old messages are still present maybe due to the snapshot that it carries.
I was able to clear the snapshot from the server by using the ItemEventListener's -> clearSnapshot(...) method but is there any other way that we can clear the snapshot from the client itself when the user performs certain action.
Giuseppe Corti
Hi Krishna Teja K,
Sorry but your scenario is not totally clear to me, but have you tried to use
removeRow?
Regards,
Giuseppe
KrishnaTejaK
Hi Giuseppe,
I checked "removeRow" but what if we want to remove all the row's, do we have any solution for that?
Giuseppe Corti
Hi Krishna Teja K,
I'm not sure if you've already come across this feature, but maybe it could be useful in your scenario:
https://sdk.lightstreamer.com/ls-web-client/9.0.0/api/AbstractWidget.html#setAutoCleanBehavior
Regards,
Giuseppe