将项目标记为TableView中新添加的项目(Marking an item as newly added in TableView)
我有一个UITableView,只需按一下按钮即可添加新项目。 我想强调这个新添加的项目。 由于UITableView是数据驱动的并且单元格是循环使用的,所以我能想到的唯一方法来标记这个新添加的项目是在数据本身中添加
BOOL
标志,然后突出显示单元格并在第一次遇到时取消标记。有没有其他方法可以做到这一点,而不必污染数据源?
I have a UITableView where I can add a new item with a touch of a button. I would like to highlight this newly added item. Since UITableView is data-driven and cells are recycled, the only way I can think of so far to mark this newly added item is to add a
BOOL
flag in the data itself, then highlight the cell and negate the flag on first encounter.Is there another way of doing this without having to contaminate the data source?
原文:https://stackoverflow.com/questions/8360628
最满意答案
通常在
WHEN-VALIDATE-ITEM
上使用GO_BLOCK
或GO_ITEM
是有限制的。 然而,有几种方法可以解决这个问题。 一种方法是使用WHEN-TIMER-EXPIRED
触发器。 这里是如何 -
WHEN-TIMER-EXPIRED
Begin if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then CALL_PROG_UNIT(); --This is your Procedure that calls the GO_BLOCK /*Do rest of validation here*/ end if; END;
WHEN-VALIDATE-ITEM
DECLARE timer_id TIMER; Begin timer_id := CREATE_TIMER('NEW_TIMER',1,NO_REPEAT); --set a short timer so that the WHEN-TIMER-EXPIRED trigger is fired immediately End;
会发生什么 - 一旦调用
CREATE_TIMER
函数,这将创建&到期计时器,然后表单级触发器WHEN-TIMER-EXPIRED
将检查过期的计时器名称并调用具有GO_BLOCK
程序单元。 希望这可以帮助。
UPDATE
Jeffery Kemp先生希望看到证明这个解决方案有效。 所以在这里 -
一个带有两个块
BLOCK1
和BLOCK2
的Oracle表单,其中包含文本项WVI触发器
WTE表格触发器。 这将首先调用带有
GO_BLOCK
函数调用的PROGRAM UNITP_CALL_PROC
,然后对字段Number 2
一些验证。这是
P_CALL_PROC
这里是结果 -
和
这是一个Youtube链接,用于查看表单的实际效果。
Usually there is a restriction on using
GO_BLOCK
orGO_ITEM
on aWHEN-VALIDATE-ITEM
. However there are a couple of ways to overcome this. One way is to use aWHEN-TIMER-EXPIRED
trigger. Here is how-
WHEN-TIMER-EXPIRED
Begin if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then CALL_PROG_UNIT(); --This is your Procedure that calls the GO_BLOCK /*Do rest of validation here*/ end if; END;
WHEN-VALIDATE-ITEM
DECLARE timer_id TIMER; Begin timer_id := CREATE_TIMER('NEW_TIMER',1,NO_REPEAT); --set a short timer so that the WHEN-TIMER-EXPIRED trigger is fired immediately End;
What happens is - This will create & expire the timer as soon as the
CREATE_TIMER
function is called and then the form level triggerWHEN-TIMER-EXPIRED
will check the expired timer name and call your program unit that has theGO_BLOCK
. Hope this helps.
UPDATE
Mr Jeffery Kemp wanted to see proof that this solution works. So here it is-
An Oracle form with two Blocks
BLOCK1
andBLOCK2
with text items on itW-V-I Trigger
W-T-E Form Trigger. This calls a PROGRAM UNIT
P_CALL_PROC
withGO_BLOCK
function call first and then does some validations on the fieldNumber 2
.Here is
P_CALL_PROC
And here is the result-
And
Here is a Youtube link to see the Form in action.
相关问答
更多-
它不起作用的原因是因为你正在构造一个字符串,然后将它与一个整数进行比较。 结果转换失败。 字符串包含看起来像SQL的东西,实际上并不执行它。 相反,您需要执行查询,例如使用EXISTS : SET TERM ^ ; CREATE TRIGGER STOP_PREMIX_INSERT_PRODUCEDD FOR PRODUCEDD ACTIVE BEFORE INSERT OR UPDATE POSITION 0 AS BEGIN IF (EXISTS (SELECT * ...
-
您可以在触发器中捕获验证错误: try { upsert financeRecord; } catch (Exception e) { // do whatever you'd like to on an exception here } You could catch the validation error in your trigger: try { upsert financeRecord; } catch (Exception e) { // do whateve ...
-
pre('save')或pre('validate')不会触发|(pre('save') or pre('validate') doesn't trigger | Mongoose)[2022-07-04]
只有在创建模型之前定义钩子时钩子才有效: var userSchema = new Schema({...}); userSchema.pre('save', function(next){ // tried with pre('validate') console.log('triggered...'); next(); }); var User = module.exports = mongoose.model('User', userSchema); Hooks only wor ... -
这是一个使用cat_tools中的trigger__parse函数的示例 ,您可以使用pgxnclient安装该函数 。 首先,一些一般设置: CREATE EXTENSION cat_tools; CREATE TABLE i(i int); 创建实际的事件触发器: CREATE OR REPLACE FUNCTION no_before_triggers() RETURNS event_trigger LANGUAGE plpgsql AS $body$ DECLARE r record; BEG ...
-
ELSIF不能在触发器内工作(ELSIF not working inside trigger)[2023-08-13]
问题是你的TRIGGER正在处理你提出的EXCEPTION ,但它并没有传递给触发它的DML。 因此, RentalType列正常插入。 因此,要么删除 EXCEPTION块,要么在EXCEPTION 添加一个简单的RAISE语句 另外,看起来像 :NEW.RentalType != 'M' OR :NEW.RentalType != 'B' 将永远是真实的。 你的意思是:NEW.RentalType != 'M' AND :NEW.RentalType != 'B' ? The problem is t ... -
因为您正在使用,所以会出现该错误. 而不是->在表达式NEW.data.ids提取ids数组。 但是你的触发器无论如何不会工作,因为你不是想避免遏制,而是重叠在数组中。 您可以编写触发器函数的一种方法是: CREATE OR REPLACE FUNCTION validate_id_constraint() RETURNS trigger LANGUAGE plpgsql AS $$DECLARE j jsonb; BEGIN FOR j IN SELECT jsonb_arr ...
-
您可以将insert更改为以下内容,以检查是否已存在重复项。 select假定my_hist的主键是id和start_date ,将where not exists子句更改为仅使用主键值(如果它们不同)。 insert into my_hist select :old.id, :old.no, :old.start_date, :old.end_date, sysdate from dual where not exists ( select 1 from ...
-
通常在WHEN-VALIDATE-ITEM上使用GO_BLOCK或GO_ITEM是有限制的。 然而,有几种方法可以解决这个问题。 一种方法是使用WHEN-TIMER-EXPIRED触发器。 这里是如何 - WHEN-TIMER-EXPIRED Begin if GET_APPLICATION_PROPERTY(TIMER_NAME) = 'NEW_TIMER' then CALL_PROG_UNIT(); --This is your Procedure that calls the ...
-
我不确定我是否理解你。 如果需要从其他表中显示原因名称,则POST-QUERY触发器是正确的,但是在DISPLAY_COMM_DET块上。 将此块作为基于CUST_COMM表的详细块。 创建非数据库项NDB_COMM_REASON_VALUE。 在DISPLAY_COMM_DET块上创建POST-QUERY触发器,如下所示: declare cursor c_reason is select comm_value from common_master where comm ...
-
看看名为SQL Search的免费 Red-Gate工具,它可以执行此操作 - 它会在整个数据库中搜索任何类型的字符串。 在您的情况下:搜索您已删除的列,并让SQL搜索找到引用该列的所有存储过程,触发器等 - >为您提供需要修复的那些事项的简单列表。 对于任何DBA或数据库开发人员来说,这是一个非常必备的工具 - 我是否已经提到它可以完全免费用于任何类型的使用? Have a look at the FREE Red-Gate tool called SQL Search which does this - ...