Jump to content

XTamplate example


x11

Recommended Posts

  • 3 weeks later...

@Sherzod не могли бы вы помочь со всплывающей подсказкой в XTemplate в данном примере?

В js-файле (в папке \Win32\Debug\files\js\) есть функция

getArc: function(val){
						if (val[sender.fieldsNames.indexOf("DELETED")]){
							return '<i style="color: red;" class="far fa-trash-alt"> </i>'}
					},

которая выводит иконку корзины, если запись помечена, как удаленная в архив.

Так вот, подскажите, как сделать так, чтобы при нажатии на эту иконку корзины всплывала подсказка ToolTip?

На форуме уже есть тема, в которой есть ваши примеры кода:

function window.beforeInit(sender, config) 
{
	createToolTip = function(combo, tip) {
		combo.labelTip = Ext.create('Ext.tip.ToolTip', {
			closable: true,
			align: 'tl',
			focusOnToFront: true,
			autoHide: true,
			autoShow: true,
			autoScroll: true
		});

		combo.labelElement.addListener('click', function(e) {
			e.preventDefault();
			if (combo.labelTip) {
				if (combo.getPlaceholder()) {
					combo.labelTip.setHtml(combo.getPlaceholder());
				} else {
					combo.labelTip.setHtml(tip);
				}
				combo.labelTip.showByTarget(combo.inputElement);
			}
		});
	};	
}

 

но я не могу ваш код применить к этому примеру (ссылка на скачивание в первом сообщении этой темы)

у меня появляются ошибки: Uncaught TypeError: Cannot read properties of undefined (reading 'addListener')

Спасибо.

Link to comment
Share on other sites

В примере добавьте одну строку кода, в строку, например, 124 ( на главной форме Mainm)

      UniMainModule.FDMemTable1DELETED.Value := True

и иконка появится

(другими словами, укажите, что запись удадена в архив)

 

Screenshot_59.jpg

Screenshot_60.jpg

Link to comment
Share on other sites

On 1/15/2022 at 3:13 PM, x11 said:

не получилось?

Добрый день,

Вы можете попробовать использовать следующий подход:

function childtap(sender, location, eOpts)
{
    if (location.sourceElement && location.sourceElement.className == 'far fa-trash-alt') {
        // custom logic
    }
}

 

Link to comment
Share on other sites

Пример:

1. 

function childtap(sender, location, eOpts)
{
    if (location.sourceElement && location.sourceElement.className == 'far fa-trash-alt') {
        ajaxRequest(sender, "_tap", [])
    }
}

2. 

procedure TMainmForm.dbgResultAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
const cEventNamePopup = 'eventPopup';

begin
  if EventName = '_tap' then
  begin
    ShowMessage(UniMainModule.FDMemTable1STREET_NAME.Value)
  end
  else if EventName = cEventNamePopup then
  begin
    fObjId   := StrToIntDef(Params.Values['objId'], 0);// dbgResult.afterCreate.js
    fIdType := StrToIntDef(Params.Values['typeId'], 0);

    popupMnuRes.Show;
  end;
end;

 

Link to comment
Share on other sites

1 minute ago, Sherzod said:
if (location.sourceElement && location.sourceElement.className == 'far fa-trash-alt') {
        ajaxRequest(sender, "_tap", [])

 

а если без участия сервера? не получится?

т.е. в браузере показать Tooltip

Link to comment
Share on other sites

1 minute ago, x11 said:

а если без участия сервера? не получится?

Можно конечно, но если честно, я этого избежал...

2 minutes ago, x11 said:

т.е. в браузере показать Tooltip

Можете хотя бы показать alert.

Link to comment
Share on other sites

function childtap(sender, location, eOpts)
{
    if (location.sourceElement && location.sourceElement.className == 'far fa-trash-alt') {
        //ajaxRequest(sender, "_tap", [])
        alert(location.record.data[12]);
    }
}
data:
0: 3
1: "APART"
2: 0
3: "USD"
4: true
5: 2
6: 2
7: 15
8: ""
9: "/files/img/nopicture100.png?20012022125058"
10: ""
11: "Region1/Region2"
12: "STREET2"
13: 140
14: 46
15: ""
16: "#000000"
17: 181
18: "32/20/12"

 

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, x11 said:

взять уже готовый ваш код и применить здесь

Думаю, в любом случае мы не можем применить готовый выше приведенный код, поскольку это не отдельный компонент, а иконка.

Придется модифицировать код.  

Link to comment
Share on other sites

×
×
  • Create New...