Jump to content

UnimDBListGrid button onclick


Ken_Sowyer

Recommended Posts

Alright, here what I done:

   '<button id={1} onclick="myFunction()">X</button>'+

Then create a .js file with an ajaxRequest, adding to CustomFiles in the ServerModule.

    function myFunction(){
         ajaxRequest(MyForm.form,"ExcluirItem",[]);
    }

Then add the OnAjaxEvent to the form.

 if EventName = 'ExcluirItem' then
  myAct.Execute;

I don't know if there's a simple way, but it's working.

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

 

Sorry, Can you clarify your question?

if my delphi form name is mainmform,my unimdblistgrid name is lst1

in lst1 unievents's beforeinit i write

 
 
function beforeInit(sender, config)
{
 config.itemTpl='<table  style="width:100%;white-space: nowrap;vertical-align:middle;">'+
                '<tr>'+
                '<td >{0}</td>'+
                '<td >{1}<input type="button" id="btn1" name="btn1" value="ClickMe" onclick="myFunction()"></td>'+
                '<td >{2}</td>'+  
                '</tr></table>'
}
 
 
How to write  the CustomFiles in the ServerModule
???
====================

function myFunction(){

ajaxRequest(??????.????,"ExcluirItem",[]);

}
=======================    
my form name is mainmform
my unimdblistgrid name is lst1          
Link to comment
Share on other sites

  • 2 years later...

@Sherzod не могли бы вы подсказать?

Я хочу добавить кнопки, с событиями, чтобы на сервер отправлять ID, т.е. значение из нулевого столбца {0}

function beforeInit(sender, config){
  config.loadMask=true;
  config.loadingText = 'загрузка...';
  config.emptyText='даних немає'; 
  config.grouped = false;
  config.selectedCls = '';
console.log(config);
console.log(sender);
console.log(this);
  
  config.itemTpl = new Ext.XTemplate('<table style="width:100%; white-space:nowrap; vertical-align:middle;">'+ 
                     '<tr>'+
                        '<td style="color:#2c81aa">ID {0}, ID на сайті: {13}</td>'+
						'<td><input type="button" id="btn1" name="btn1" value="ClickMe" onclick="this.myFunction(????)"></td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td>ДОЗ: {1}</td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td>{2}</td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td style="padding-top:3px;">{3}; {4}, {5}</td>'+
                     '</tr>'+
                     
                                
                 '</table>',
				 {
					 myFunction: function(val){
						 ajaxRequest(this, 'myFunction', ['val=' + val])
					 }
					 
					 
				 }
				 );
  

			
}

Кнопка появляется.

Но что и как передать в качестве параметра

 onclick="this.myFunction(????)"

что написать вместо ????

Спасибо.

Screenshot_14.jpg

Link to comment
Share on other sites

Сейчас при клике я получаю ошибку

Quote

m:1 Uncaught TypeError: this.myFunction is not a function
    at HTMLInputElement.onclick (m:1)
onclick @ m:1

 

Link to comment
Share on other sites

1 hour ago, x11 said:

Я хочу добавить кнопки, с событиями, чтобы на сервер отправлять ID, т.е. значение из нулевого столбца {0}

Ок, я проверю. 

Link to comment
Share on other sites

4 hours ago, x11 said:

Но что и как передать в качестве параметра

Может быть, так попробуете?

function beforeInit(sender, config)
{
    var me=sender;
    me.myFunction = function(id) {
        alert(id);
    };
    var nm=config.id.replace('_id', '');
    
    config.itemTpl = new Ext.XTemplate('<table style="width:100%; white-space:nowrap; vertical-align:middle;">'+ 
                     '<tr>'+
                        '<td style="color:#2c81aa">ID {0}, ID на сайті: {13}</td>'+
						'<td><input type="button" id="btn1" name="btn1" value="ClickMe" onclick="'+ nm +'.myFunction({0});"></td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td>ДОЗ: {1}</td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td>{2}</td>'+
                     '</tr>'+
                     
                     '<tr>'+
                        '<td style="padding-top:3px;">{3}; {4}, {5}</td>'+
                     '</tr>'+
                     
                                
                 '</table>'
				 );
}

 

  • Like 1
Link to comment
Share on other sites

ошибка

Quote

Uncaught TypeError: fmmmyobjects_dbgmyobjects_0.myFunction is not a function
    at HTMLInputElement.onclick (m:1)
onclick @ m:1

 

При копировании убрал лишние знаки "?", т.к. появилось пара вопросительных знаков.

Screenshot_19.jpg

Link to comment
Share on other sites

4 hours ago, x11 said:

у меня в настройках...

 

Другое решение, попробуйте:

function beforeInit(sender, config) 
{
    config.itemTpl = new Ext.XTemplate('<table style="width:100%; white-space:nowrap; vertical-align:middle;">' +
        '<tr>' +
        '<td style="color:#2c81aa">ID {0}, ID на сайті: {13}</td>' +
        '<td><input class=".btn1" type="button" value="ClickMe" data-id="{0}"></td>' +
        '</tr>' +

        '<tr>' +
        '<td>ДОЗ: {1}</td>' +
        '</tr>' +

        '<tr>' +
        '<td>{2}</td>' +
        '</tr>' +

        '<tr>' +
        '<td style="padding-top:3px;">{3}; {4}, {5}</td>' +
        '</tr>' +

        '</table>'
    );
}
function afterCreate(sender) 
{
    Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
        if (target.getAttribute('class') === '.btn1') {
            alert(target.getAttribute('data-id'));
        }
    }, null, {
        delegate: 'table input'
    });
}

 

  • Like 2
Link to comment
Share on other sites

function afterCreate(sender)
{
   Ext.getCmp(sender.id).bodyElement.addListener('click', function(event, target) {
        if (target.getAttribute('class') === '.btn1') {
            ajaxRequest(this, "editid", [target.getAttribute('data-id')]);
        }
    }, null, {
        delegate: 'table input'
    });
}

Что здесь может быть не так?

Вижу, в консоли браузера отправляется запрос. Но в программу не приходит. Т.е. событие TfmmMyObjects.dbgMyObjectsAjaxEvent() не срабатывает

 

Screenshot_2.jpg

Link to comment
Share on other sites

Не могу понять, почему кнопки уехали влево.

Подскажите, как сделать, чтобы кнопки были выровнены по правому краю.

Спасибо.

Screenshot_1.jpg

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...