Here the code which i have used for show the tick mark in table row,On each row click tick mark showing and on other click its hiding.I added a button to select make all ticks visible(Select all),it not working.
local function onRowRender( event )
local phase = event.phase
local row = event.row
chktick= display.newImage('images/kitchen/checktick.png',10,10);
if(deviceName == "iPhone" or deviceName == "iPad") then
chktick.x=303;
chktick.isVisible = false;
else
chktick.x=303;
chktick.isVisible = false;
end
chktick.y=row.contentHeight * 0.5;
row:insert(chktick);
row:addEventListener("tap",onRowTouch);
return true;
end
On rowtouch method
local function onRowTouch( event )
local row = event.target;
local _chktick = event.target[6];
print("Comes here when touch"..row.index);
if(flagvalue==1)then
_chktick.isVisible = true;
flagvalue=0;
else
_chktick.isVisible = false;
flagvalue=1;
end
return true;
end
Select all method
local function SelecetAllEventListener( event )
flagvalue=1;
currentScene.reloadScene();
return true;
end
Rowrender calling code
function scene:enterScene( event )
MenuID = event.params.currentMenuID;
local group = self.view
tableView = widget.newTableView
{
top = 85,
left = 0,
width = 320,
height = 380,
maskFile = "billmask.png",
hideBackground = true,
onRowRender = onRowRender,
listener = tableViewListener,
}
end
group:insert( tableView )
end
Please help me how to make visible all tick showable in using SelecetAllEventListener?
The problem could be that in your "select all" handler (SelecetAllEventListener
) you are setting a flag to 1 then reloading the scene. This will cause, IIUC, the onRowRender to be called again, but it won't cause the onRowTouch to be called again (since there hasn't been a touch of a row). What you need to do is that in SelecetAllEventListener
you loop over all your rows and change the visibility of the checkmark. Your code doesnt' show where you keep your rows but I will assume in a variable:
local tableRows = {}
local toggle = true
local function somewhereInYourCode()
...
newRow = ...
yourTable:inserRow(newRow) -- will cause onRowRender to get called
table.insert(tableRows, newRow)
...
end
local function SelecetAllEventListener( event )
for i,row in ipairs(tableRows) do
row[6].isVisible = toggle
end
toggle = not toggle -- for next time
return true
end
Your code doesn't show where you insert rows so I put it in somewhereInYourCode()
but you get the idea.